5

If I render to a bitmap then the bitmap has a specific number of pixels and a DPI. That combination makes it easy to draw a square that is 1" x 1" - I render lines for each side that are DPI pixels long.

When I create a SVG, I think it should still be able to be set this way. Where I set the units per inch and also the size in those units of the object as a whole. Yes you can zoom on a SVG file as it's all vectors, but it should still have a 100% zoom size to render to.

In my case I am using EMUs for my units. So 914400 units/inch. So question #1 is, how do I set the scaling using Batik. For a bitmap it's:

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

But there is no dpi equivalent for SVG.

And then for a given width & height that is in EMUs, do I set the size (or maximum extent) of the image using:

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

I think I'm not fully understanding SVG, or at least Batik as I don't see how to set the units to render at for a 100% zoom.

David Thielen
  • 22,779
  • 27
  • 83
  • 163

0 Answers0