- Rectangle2D destination = new Rectangle2D.Double(0,0,1000,1000);
- double sx = destination.getWidth() / content.getWidth();
- double sy = destination.getHeight() / content.getHeight();
- double scale = sx < sy ? sx : sy;
-
- // Set svgCanvasSize to the given size parameters
- svgGenerator.setSVGCanvasSize(new Dimension((int)(scale * content.getWidth()), (int)(scale * content.getHeight())));
- svgGenerator.setClip(content);
-
- double trX = -1 * content.getX();
- double trY = -1 * content.getY();
-
- // NaNs
- if(!Double.isFinite(trX)) trX = 0;
- if(!Double.isFinite(trY)) trY = 0;
+ svgGenerator.setSVGCanvasSize(new Dimension((int)Math.ceil(scale * content.getWidth()) + 2*offset, (int)Math.ceil(scale * content.getHeight()) + 2*offset));
+ //svgGenerator.setClip(content);