Hello,
I am afraid I get the same annoying result using Rendering Transform. In the Image Transcoder Tutorial it sais


"The KEY_AOI enables to select the region of the SVG document to render. The value of this key must be a Rectangle specified in pixels and described in the SVG document's space". (this last part is not really clear to me, actually)

So they must be pixel values, from the outermost SVG element (the canvas?), as you say, maybe using the Rendering Transform, but what exactly are we supposed to transform? The viewbox? I think I tried every single combination between transforms, viewboxes and canvas width/height.

Maybe a composed transform? If I get the actual viewbox using the viewboxTransform (the code below), that gives me the right values, but those are not pixel values. Maybe applying later the rendering transform to those values? This sounds confusing, at least.

Cheers,

Nacho

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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--


-------------------------------------------------------------------------------
Ignacio Leon


CERN -- European Laboratory for Particle Physics
IT/CS Network Services and Operation
Mailbox: G23910
CH-1211 Genève 23, Switzerland Office : (+41) (0) 22 76 75 590 [EMAIL PROTECTED] -------------------------------------------------------------------------------



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to