Hi,
I am trying to set two attributes for my 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("preserveAspectRatio", "xMinYMin meet");
rootElement.setAttribute("viewBox", "0 0 " +
Integer.toString(imageWidth) + " " + Integer.toString(imageHeight));
graphics2D = svgGenerator;
This code is taken from examples I found, graphics2D is then used to create
an image with drawLine, drawString, ...
In my svg the preserveAspectRatio is used as expected, but the viewBox
attribute is missing.
I also tried to remove the setSVGCansasSize, but this changed anything.
The user of my images needs the following attributes:
preserveAspectRatio="xMinYMin meet" viewBox="0 0 width height" (width and
height are the size of the image), currently I am using height="height" and
width="width") which doesn't fit his needs.
What do I have to do that the viewBox attribute will be used?
Regards,
Eddie
--
View this message in context:
http://batik.2283329.n4.nabble.com/problem-setting-viewbox-tp4656184.html
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]