I need to set the height and width of the svg file generated by JFreeChart. It is caused by I'm using svg to my html page (after all its pdf), and when I don't set any styles the image rendered in half.
DOMImplementation mySVGDOM= GenericDOMImplementation.getDOMImplementation();
/* create Document object */
Document document = mySVGDOM.createDocument(null, "svg", null);
document.createAttribute("width");
document.getDocumentElement().setAttribute("width", "1200px");
/* Create SVG Generator */
SVGGraphics2D my_svg_generator = new SVGGraphics2D(document);
/* Render chart as SVG 2D Graphics object */
chart.draw(my_svg_generator, new Rectangle2D.Double(0,0,1200,480));
/* Write output to file */
my_svg_generator.stream("output_pie_chart.svg");
return IOUtils.readUtf(new File("output_pie_chart.svg"));
The final result:
<svg width="1200px" height="1200px" fill-opacity="1" ...
This is currently:
<svg fill-opacity="1" ...
I would like to add width and height.