Setting SVG file size (via Batik)

If I render a bitmap, then the bitmap has a certain number of pixels and DPI. This combination makes it easy to draw a square that is 1 "x 1" - I draw lines for each side whose length is DPI.

When I create an SVG, I think it should still be configured that way. Where I set the units per inch, as well as the size in these units of the object as a whole. Yes, you can enlarge the SVG file like all vectors, but it should still have a zoom size of 100% for rendering.

In my case, I use EMU for my units. So there are 914,400 units / inch. So, question number 1: how to set the scaling using Batik. For a bitmap, this is:

AffineTransform scaleToEmus = AffineTransform.getScaleInstance(dpi / (float) DrawingSurface.EPI, dpi / (float) DrawingSurface.EPI); graphics.transform(scaleToEmus); 

But for SVG there is no dpi equivalent.

And then for a given width and height that are in the EMU, do I set the size (or maximum degree) of the image using:

 svgGraphics.setSVGCanvasSize(new Dimension(width, height)); 

I think I don’t fully understand SVG, or at least Batik, because I don’t see how to set up units for rendering for a 100 percent increase.

+5
source share

Source: https://habr.com/ru/post/1239739/


All Articles