You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Magnus Pettersson <Ma...@trab.se> on 2000/06/28 10:48:04 UTC
Embedded FOP and SVG question
I'm producing PDF-documents in a java servlet. If I add SVG content in the
fo-file the process fails.
Do I have to initialize the driver in some special way so it can render SVG?
Here is my current initialization of the driver:
InputSource infilestream;
infilestream=new InputSource("in_foo.xml");
SAXParser parser =new SAXParser();
try{
// Create and initialize driver
Driver driver = new Driver();
driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",version);
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
// Output file
FileWriter fw=new FileWriter("output.pdf");
driver.setWriter(new PrintWriter(fw));
// Process
driver.buildFOTree(parser,infilestream);
driver.format();
driver.render();
//outstream.println("PDF-document created.");
//outstream.flush();
fw.close();
}
catch (org.apache.fop.apps.FOPException e){}
As you can see the SVGElementMapping is added, but it doesn't work.
Part of the fo-file (in_foo.xml):
...
...
<fo:block text-align="start" space-after.optimum="3pt"
line-height="15pt" font-family="sans-serif" font-size="12pt">This is some
text.</fo:block>
<svg:svg width="200pt" height="200pt">
<svg:text x="20pt" y="150pt">Hello SVG!</svg:text>
</svg:svg>
</fo:flow>
</fo:page-sequence>
</fo:root>
Thanks
::magnus
********************************************
Magnus Pettersson
Telia Prosoft
Phone: +46 60 144663
Mobile: +46 709 524 513
E-mail: magnus.xx.pettersson@trab.se
Address: Box 883, 851 24 Sundsvall, Sweden
********************************************