Hi Ryan,
"Ryan Breidenbach" <[email protected]> wrote on 12/04/2009
01:19:27 PM:
> I have an SVG image loaded as a GraphicsNode object. This SVG image
> has a clip area that I want to render. So far, this is how I am doing
it:
>
> // find the bounds of the clip area
> int width = graphicsNode.getPrimitiveBounds().getBounds().width
+ 2;
> int height =
graphicsNode.getPrimitiveBounds().getBounds().height + 2;
>
> // create an Graphics object the same size as the clip area (for
my PDF document)
> PdfTemplate template = pdf.createTemplate(width, height);
> Graphics2D graphics = template.createGraphics(width, height);
>
> // paint the SVG onto the graphics
> try {
> graphicsNode.primitivePaint(graphics);
> } finally {
> graphics.dispose();
> }
>
> This works fine when the clip area is positioned at the (0, 0) x ? y
> coordinates. This breaks down, however, with the clip area is in the
> ?middle? of the entire SVG image.
In this case you need to translate the clipped area to position (0,0).
I'm not familiar with your PDF engine but probably you can manage it with,
graphics.translate(-graphicsNode.getPrimitiveBounds().getBounds().x,
-graphicsNode.getPrimitiveBounds().getBounds().y);