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. I know this should be straightforward
(maybe something like using the setClip() method? Use a filter?), but I
am struggling with exactly how to do this. The Batik API is very
specialize to the graphics domain, so it is very hard for the lay person
to grok. I have searched for clip example with no success.

 

I have been struggling with this for days now and cannot figure how to
do this. Any help would be appreciated.

 

Ryan

 


########################################################################
"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