You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Denis Weerasiri <dd...@gmail.com> on 2008/11/13 07:50:29 UTC

Format the generated svg file using Batik

Is there a possible way in Batik to change the format of the svg file.
I tried SVG pretty printer. But it seems that it does not change the format
of the SVG file, it just print on the screen the formatted output.
Please correct me if I'm wrong.
Thank you.

Re: Format the generated svg file using Batik

Posted by Gentle Yang <ya...@genomics.org.cn>.
I know there is a "format" or "pretty" function in some Java libs for XML .

For example: In Dom4J , you can format your xml like this:

... ...
OutputFormat f = OutputFormat.createPrettyPrint();
f.setEncode('gb2312')
XMLWriter w = new XMLWriter( out, f);
w.write(document);
w.close();

... ...

Denis Weerasiri 写道:
> Thank you for the attention.
> But do you know a possible way only using Batik library?


Re: Format the generated svg file using Batik

Posted by Denis Weerasiri <dd...@gmail.com>.
Thank you for the attention.
But do you know a possible way only using Batik library?

Re: Format the generated svg file using Batik

Posted by Gentle Yang <ya...@genomics.org.cn>.
Hi denis:

I used the Eclipse plugin --- Batik svg plugin ; I can browse svg 
file(xml file) freely ,and also format it with "Ctrl+Shift+f" .
And also I can browse my svg figure realtime when changing the xml file .

Eclipse svg plugin project on sourceforge named "svgplugin":   
http://sourceforge.net/projects/svgplugin 
<http://sourceforge.net/projects/svgplugin>

Good luck.

GentleYang in Shenzhen,China



Denis Weerasiri ??:
> Is there a possible way in Batik to change the format of the svg file.
> I tried SVG pretty printer. But it seems that it does not change the 
> format of the SVG file, it just print on the screen the formatted output.
> Please correct me if I'm wrong.
> Thank you.


RE: Format the generated svg file using Batik

Posted by Nirmesh Desai <nd...@autonomy.com>.
Using TransformerFactory could help.

 

    Transformer  trnfrmr =
TransformerFactory.newInstance().newTransformer();

    DOMSource    domsrc  = new DOMSource(svgDoc.getFirstChild());

    StringWriter sw      = new StringWriter();

    StreamResult res     = new StreamResult(sw);

        

    trnfrmr.transform(domsrc, res);

 

br,

Nirmesh.

________________________________

From: Denis Weerasiri [mailto:ddweerasiri@gmail.com] 
Sent: Wednesday, November 12, 2008 10:50 PM
To: batik-users@xmlgraphics.apache.org
Subject: Format the generated svg file using Batik

 

Is there a possible way in Batik to change the format of the svg file.
I tried SVG pretty printer. But it seems that it does not change the
format of the SVG file, it just print on the screen the formatted
output.
Please correct me if I'm wrong.
Thank you.