Thanks Michael Bishop...
I tried Transcoder as follows and am getting exception as
element
[Ljava.lang.StackTraceElement;@1de256f
The code I tried with is as follows(my svg should be saved as a file):
DOMImplementation dom = SVGDOMImplementation.getDOMImplementation();
SVGDocument document =
(SVGDocument)dom.createDocument(SVGDOMImplementation.SVG_NAMESPACE_URI,
"svg", null); SVGGeneratorContext ctx =
SVGGeneratorContext.createDefault(document);
ctx.setEmbeddedFontsOn(false);
boolean textAsShapes = false;
SVGGraphics2D g2 = new SVGGraphics2D(ctx, textAsShapes);
g2.setSVGCanvasSize(new java.awt.Dimension(height,width));
// tell JFreeChart to draw itself into the SVG
chart.draw(g2, new Rectangle(0, 0, height,width), null);
// Write svg file
OutputStream outputStream = new FileOutputStream(svgFileName);
Writer out = new OutputStreamWriter(outputStream);
final TranscoderInput input = new TranscoderInput(document);
final TranscoderOutput output = new TranscoderOutput(out);
final Transcoder transcoder = new SVGTranscoder();
transcoder.addTranscodingHint(SVGTranscoder.KEY_DOCTYPE,
SVGTranscoder.VALUE_DOCTYPE_REMOVE);
transcoder.transcode(input, output);
outputStream.flush();
outputStream.close();
Am getting this error at transcoder.transcode(input, output); Can you please
tell me what I am missing here..Thanks in advance.
Bishop, Michael W. CTR USJFCOM JFL wrote:
>
> I've had to do this before and found the Transcoder API to be most
> helpful:
>
> final SVGDocument svgDocument = ...;
> final StringWriter writer = new StringWriter();
> final TranscoderInput input = new TranscoderInput(svgDocument);
> final TranscoderOutput output = new TranscoderOutput(stringWriter);
> final Transcoder transcoder = new SVGTranscoder();
>
> transcoder.addTranscodingHint(SVGTranscoder.KEY_DOCTYPE,
> SVGTranscoder.VALUE_DOCTYPE_REMOVE);
> transcoder.transcode(input, output);
>
> final String docAsString = writer.toString();
>
> Same reason too; I was using systems that weren't connected to the
> Internet and needed to load documents without resolving the DOCTYPE
> header.
>
> Michael Bishop
>
> ________________________________
>
> From: ninitha [mailto:[email protected]]
> Sent: Mon 8/31/2009 7:13 AM
> To: [email protected]
> Subject: Re: Removing DOCTYPE in the SVG XML
>
>
>
>
> Hi Thomas,
>
> Thanks for your reply..Can you please let me know how to output the
> fle
> using
> batik.dom.util.DOMUtilities.writeDocument. It will be very helpful if you
> do
> so.
>
> Thanks once again.
>
> thomas.deweese wrote:
>>
>> Hi Ninitha,
>>
>> ninitha <[email protected]> wrote on 08/31/2009 05:26:33 AM:
>>
>>> I am converting jFreeCharts to SVG. When I load in one of the
>> XSL FO
>>> Processor(Render X XEP), it throws time out error at the line <!DOCTYPE
>> svg
>>> PUBLIC '-//W3C//DTD SVG 1.0//EN'
>>> 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
>>> If the line is removed, the XSL FO is processed and converted to PDF. So
>> is
>>> there a way to remove the line in the resulting SVG XML before saving
>> the
>>> file.Following is the code used to get the SVG file.
>>
>> This should really be fixed in your XSL FO Processor, it's trying to
>> read that doctype and presumably you aren't directly connected to the
>> internet. There are generally ways to configure XML parsers to either
>> skip the Doctype or redirect certain known doctypes (like SVG) to a
>> local instance of the doctype.
>>
>>> // Write svg file
>>> OutputStream outputStream = new FileOutputStream(svgFileName);
>>
>>> Writer out = new OutputStreamWriter(outputStream, "UTF-8");
>>> g2.stream(out, true);
>>
>> The SVGGraphics2D automatically emits the default SVG doctype. You
>> can bypass the Graphics2D stream method and write the SVG Document using
>> some other XML serializer. One possible replacement would be
>> batik.dom.util.DOMUtilities.writeDocument.
>>
>>
>>
>
> --
> View this message in context:
> http://www.nabble.com/Removing-DOCTYPE-in-the-SVG-XML-tp25220586p25221829.html
> Sent from the Batik - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> 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]
>
--
View this message in context:
http://www.nabble.com/Removing-DOCTYPE-in-the-SVG-XML-tp25220586p25235024.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]