That did the trick. Thanks a ton for the help.

 

From: [email protected] [mailto:[email protected]] 
Sent: Sunday, December 06, 2009 6:57 AM
To: [email protected]
Cc: [email protected]
Subject: Re: Rendering the clipped area on an SVG to a Graphics2d object

 

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); 


########################################################################
"This email message, including any attachments, is for the sole use of the 
intended recipients and may contain confidential and privileged information.  
Unauthorized use, disclosure or distribution of this email is strictly 
forbidden.  If you have received this message in error, please reply to the 
above sender notifying them of this error, and then kindly delete the message."
########################################################################

Reply via email to