xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: Printing with Rendering Transform/Results
Date Thu, 04 Mar 2004 15:34:52 GMT
Nacho wrote:
> Hello,
> 
> I tried to perform the same action as Chris Cruzdal, that is, to print 
> just the piece of the canvas that can be seen on the screen. I used the 
> Print Transcoder, and I cannot make it work, I always get to print a 
> nice white page.
> Is it a problem of my code? It is like follows (base on the Image 
> Transcoder Tutorial)
> 
> // I get the ViewBox transform
> AffineTransform aft = svgCanvas.getViewBoxTransform();

Hi Nacho, Chris,

    So upon closer examination the problem is that the coordinate
system for the AOI is the coordinate system of the 'width/height'
elements on the outermost SVG (in other words not the viewBox).
So I think you need to replace 'getViewBoxTransform()' above with
getRenderingTransform().


> 
> // Now I extract the measures of the canvas I am using
> Rectangle canvasRect = svgCanvas.getBounds();
> 
> try{
>     AffineTransform invt = aft.createInverse();
>                        
>     Rectangle iRect = invt.createTransformedShape(canvasRect).getBounds();
> 
>     PrintTranscoder pt = new PrintTranscoder();
>     
>     // Set transcoding hints           
>     //...
>     
>     pt.addTranscodingHint(PrintTranscoder.KEY_WIDTH, new 
> Float(iRect.getWidth()));
>     pt.addTranscodingHint(PrintTranscoder.KEY_HEIGHT, new 
> Float(iRect.getHeight()));
>     pt.addTranscodingHint(PrintTranscoder.KEY_AOI, iRect);
> 
>     pt.transcode(new 
> TranscoderInput(svgCanvas.getSVGDocument()),null);                                
> 
> 
>     // Print
>     try {
>         pt.print();
>     }
>     catch (PrinterException ex)     {}
> }
> catch (NoninvertibleTransformException e)
> {}
> 
> The rectangle I get has the right values, it measures exactly the piece 
> of the canvas I am using at that moment, but somehow it doesn't work, 
> maybe my transcoding hints are not right.
> 
> Any help would be very welcome.
> 
> Thanks,
> 
> Ignacio
> 
> 
>> Hi,
> 
> 
>>>     You can probably get this by transforming the
>>> JSVGCanva's bbox (0,0) -> (comp.w, comp.h) to the
>>> viewBox coordinate system.  This can be done by
>>> using canvas.getViewBoxTransform().
> 
> 
>> This works (kind of) when I print the JSVGComponent
>> using a method that gets the Graphics2d behind the
>> JSVGComponent and then directly uses the Java Printing
>> API without any interference of the Batik transcoder,
>> but has the big drawback that --- I guess because of
>> not using the transcoder --- the quality of the
>> printout is not very satisfying: it works for normal
>> A4 pages (about 30 cm high and 20 cm wide), but for A0
>> pages (about 120 cm high and 90 cm wide) the
>> resolution is just not enough.
> 
> 
>> Just to make sure, there is no way to just pass an
>> affine transformation to the PrintTranscoder which
>> then automagically applies this affine transformation?
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Mime
View raw message