xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Irene Heinz <irene.he...@web.de>
Subject Printing a part of a SVG
Date Mon, 22 Aug 2005 13:24:51 GMT

Hi all,

I implemented the printing function for SVG, using the transcoder, which works very well.
Now I am trying to print only the part of the SVG which is currently visible, and I am somehow
stuck. After some trial and error, my code is now as follows:

 PrintTranscoder prm = new PrintTranscoder();
 TranscoderInput ti = new TranscoderInput(graphic);
 Rectangle rect = svgCanvas.getVisibleRect();
 AffineTransform af = svgCanvas.getViewBoxTransform();
 double ax = 0;
 double ay = 0;
 AffineTransform ai = af.createInverse();
 ax = ai.getTranslateX();
 ay = ai.getTranslateY();
 } catch(NoninvertibleTransformException err) {

 double sx = af.getScaleX();
 double sy = af.getScaleY();
 Rectangle rect1 = new Rectangle();

 prm.addTranscodingHint(PrintTranscoder.KEY_HEIGHT,new Float(rect1.height));
 prm.addTranscodingHint(PrintTranscoder.KEY_WIDTH,new Float(rect1.width));
 prm.transcode(ti, null);

svgCanvas is of type SVGView.

I am already in the right region of the SVG, and the scaling seems to work, but I always have
an offset in x-direction. The printout is cut off at the left side. When I have an SVG where
some elements are labelled A,B,C etc. from left to right, I never see letter A in the print
(however, I see one letter more than on screen).

Can anyone tell me how to get rid of this offset? Is there any better way of printing the
visible part?

Thanks, Thea

Mit der Gruppen-SMS von WEB.DE FreeMail k├Ânnen Sie eine SMS an alle 
Freunde gleichzeitig schicken: http://freemail.web.de/features/?mc=021179 

View raw message