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 Priscilla_ <lu...@hotmail.com> on 2012/03/23 15:16:15 UTC

Exporting chart into SVG

Hello, 
First of all, sorry for my bad English, 
I would like to export my generated chart in SVG format in order to generate
a PDF using Apache FOP. 
It seems my generated SVG file is not correct : when I use any other SVG
(externally downloaded) my PDF is perfect. but with the SVG generated with
Batik, just like documentation says, there's no errors but my PDF is empty. 

I edited the SVG file manually and it seems that when I replace this line: 

<svg xmlns:xlink="http://www.w3.org/1999/xlink" style="fill-opacity:1;
color-rendering:auto; color-interpolation:auto; stroke:black;
text-rendering:auto; stroke-linecap:square; stroke-miterlimit:10;
stroke-opacity:1; shape-rendering:auto; fill:black; stroke-dasharray:none;
font-weight:normal; stroke-width:1; font-family:'Dialog'; font-style:normal;
stroke-linejoin:miter; font-size:12; stroke-dashoffset:0;
image-rendering:auto;" xmlns="http://www.w3.org/2000/svg"> 

with this line: 

<svg xmlns:xlink="http://www.w3.org/1999/xlink" style="fill-opacity:1;
color-rendering:auto; color-interpolation:auto; stroke:black;
text-rendering:auto; stroke-linecap:square; stroke-miterlimit:10;
stroke-opacity:1; shape-rendering:auto; fill:black; stroke-dasharray:none;
font-weight:normal; stroke-width:1; font-family:'Dialog'; font-style:normal;
stroke-linejoin:miter; font-size:12; stroke-dashoffset:0;
image-rendering:auto;" xmlns="http://www.w3.org/2000/svg" 
width="800" height="800"> 

So I just add width and height clauses, and it worked fine ! 

So, I need to change that in my SVG generation, I tried to add these lines: 

svgGenerator.getRoot().setAttribute("width", "800"); 
svgGenerator.getRoot().setAttribute("height", "800"); 

But it seems that doesn't work : I tried to read the value of theses
attributes after, and these are empty. 

Is there any mean I can use to change that? 

I already tried this: 
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation(); 
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI; 
Document doc = impl.createDocument(svgNS, "svg", null); 

// Get the root element (the 'svg' element). 
Element svgRoot = doc.getDocumentElement(); 

// Set the width and height attributes on the root 'svg' element. 
svgRoot.setAttributeNS(null, "width", "400"); 
svgRoot.setAttributeNS(null, "height", "450"); 

but it didn't work neither
-- 
View this message in context: http://old.nabble.com/Exporting-chart-into-SVG-tp33544658p33544658.html
Sent from the FOP - Dev mailing list archive at Nabble.com.