Further to my original post, I've trawled the archives and tried a few other
ways of including the stylesheet, although it has largely been trial and
error, (mostly error!).
If I try to include my stylesheet using the code below I get the exception
that follows:
Element css = doc.createElement(SVGConstants.SVG_STYLE_TAG);
css.setAttributeNS(null, "type", "text/css");
css.setAttributeNS(null, "xlink:href",
"http://localhost:7001/SVGWeb/style.css");
svgRoot.appendChild(css);
Exception:
org.w3c.dom.DOMException: Null Document reference:
Invalid CSS document.
at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown
Source)
at org.apache.batik.css.engine.CSSEngine.parseStyleSheet(Unknown
Source)
So Im guessing the stylesheet is not being found now?
Any help gratefully received.
Kind regards,
Dylan
-----Original Message-----
From: Dylan Browne [mailto:[EMAIL PROTECTED]
Sent: 11 April 2006 11:13
To: [email protected]
Subject: CSS ignored when exporting to JPG
Hi,
I have a problem when attempting to rasterize an SVG document created using
the Batik DOM classes. It looks like the rasterize process is not picking up
the stylesheet I am importing.
I include my stylesheet like this (this works fine in so far as rendering
SVG in the browser goes):
ProcessingInstruction pi = null;
// import the stylesheet
pi = doc.createProcessingInstruction("xml-stylesheet", Config.CSS);
doc.insertBefore(pi, doc.getDocumentElement());
When I am creating my JPG, I use the following code. This does generate the
jpg, but any elements which are styled are not picked up so I end up with a
largely black image with a few shapes visible:
public void streamSVGIntoImageFormat(SVGDocument doc) {
try {
// create a JPEG transcoder
JPEGTranscoder t = new JPEGTranscoder();
// set the transcoding hints
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
// create the transcoder input
TranscoderInput input = new TranscoderInput(doc);
// create the transcoder output
OutputStream ostream = new FileOutputStream("c:\\out.jpg");
TranscoderOutput output = new TranscoderOutput(ostream);
// save the image
t.transcode(input, output);
// flush and close the stream then exit
ostream.flush();
ostream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
Does this look like an issue with how I import my stylesheet, or an issue
with how I am calling the Transcoder code?
Thanks in advance for any help,
Kind regards,
Dylan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]