Hi,
I already asked about this some time ago
(http://batik.2283329.n4.nabble.com/problem-setting-viewbox-td4656184.html).
I am not able to set the viewbox attribute in the svg (as attribute viewbox in
the XML element svg).
DOMImplementation impl = SVGDOMImplementation.getDOMImplementation();
String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;
SVGDocument document = (SVGDocument) impl.createDocument(svgNS, "svg",
null);
SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
Dimension dimension = new Dimension();
dimension.setSize(imageWidth, imageHeight);
svgGenerator.setSVGCanvasSize(dimension);
final SVGSVGElement rootElement = document.getRootElement();
rootElement.setAttribute("viewBox", "0 0 " + Integer.toString(imageWidth)
+ " " + Integer.toString(imageHeight));
Debugging through the code I found out that the attribute is added to the
attribute list (in the firstChild of SVGDocument) as expected. It gets lost
when creating the image with
Writer out = new OutputStreamWriter(outputStream, "UTF-8");
((SVGGraphics2D) graphics2D).stream(out, useCSS);
In this method the following statement:
Element svgRoot = getRoot();
Creates a new Element which is missing the viewBox attribute. When I add it
again manually (in the debugger), the expected svg is created.
Otherwise, SVGGraphics.stream creates a DocumentFragment svgDocument whose
child contains an SVGOMAnimatedRect viewBox. But this doesn't seem to be used
(at least I couldn't find it).
Do I have to do anything else except adding the viewbox attribute (e.g.
configuring something) or is batik not able to handle this?
Regards,
Eddie
------------------------------------------------------------------------------
FIZ Karlsruhe - Leibniz-Institut für Informationsinfrastruktur GmbH.
Sitz der Gesellschaft: Eggenstein-Leopoldshafen, Amtsgericht Mannheim HRB
101892.
Geschäftsführerin: Sabine Brünger-Weilandt.
Vorsitzender des Aufsichtsrats: MinDirig Dr. Thomas Greiner.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]