You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Scott Ruffner <sr...@phy.ucsf.edu> on 2006/01/17 15:43:05 UTC

Using PrintTranscoder in Batik 1.5 vs 1.6

Hi, 

I'm trying to use PrintTranscoder to print an SVG document as 
Java 2D graphics via the Java Print Service API...

PrintTranscoder printable = new PrintTranscoder();
printable.addTranscodingHint(....);
printable.transcode( new TranscoderInput(mySVGDocument), null );
Doc simpleDoc = new SimpleDoc( printable, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null );
printJob.print( simpleDoc, printAttrs );

This worked fine in Batik 1.5, but I'm running into 
problems in 1.6 : the printed output is scaled 
incorrectly.  I noticed this code snippet in the 1.5 
version of PrintTranscoder.print( Graphics, PageFormat, int)

// Check hint to know if scaling is really needed
Boolean scaleToPage = (Boolean)hints.get(KEY_SCALE_TO_PAGE);
if(scaleToPage != null && !scaleToPage.booleanValue()) {
   // Printing Graphics is always set up for 72dpi, so scale
   // according to what user agent thinks it should be
   double pixSzMM = userAgent.getPixelUnitToMillimeter();
   double pixSzInch = (25.4/pixSzMM);
   scale = 72/pixSzInch;
}
.....
g.scale(scale, scale);

This scale correction does not appear in the 1.6 version 
of PrintTranscoder, AFAIK.  Any suggestions?  Am I 
missing something?

Thanks!

Scott Ruffner