Hello,
I have a problem with printing an svg...
When the svg contains a stylesheet with fill-opacity or stroke-opacity
javas printing with the java.awt.print.Printable is very very slow. The
Printing process calls the interface method print about 50 Times befor
the svg image has finished rendering. When i use the same svg without
that opacity property in the stylesheets the print method is called only
3 Times and printing is much more faster... (70 Seconds vs. 20 Seconds
on an A3 Color printer)
I dont't know why ?! Is there a better way to print the svg ? I mean i
tried this one as well but the output is not nice because of the size of
the image and the A3 Sheet...
BufferedImage image = new BufferedImage((int) (pf.getWidth() +
0.5),
(int) (pf.getHeight() + 0.5),
BufferedImage.TYPE_INT_RGB);
....
rendering
....
ByteArrayOutputStream baos=new ByteArrayOutputStream();
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder( baos );
encoder.encode( image );
byte [] fileData= baos.toByteArray();
PrintRequestAttributeSet pras = new
HashPrintRequestAttributeSet();
pras.add(new Copies(1));
pras.add(OrientationRequested.LANDSCAPE);
pras.add(MediaSizeName.ISO_A3);
logger.error("3 " + (System.currentTimeMillis() -befor));
PrintService pss[] = PrinterJob.lookupPrintServices();
if (pss.length == 0)
throw new RuntimeException("No printer services
available.");
PrintService ps = pss[6];
System.out.println("Printing to " + ps);
logger.error("4 " + (System.currentTimeMillis() -befor));
DocPrintJob job = ps.createPrintJob();
Doc doc = new SimpleDoc(new ByteArrayInputStream(fileData),
DocFlavor.INPUT_STREAM.GIF, null);
try {
job.print(doc, pras);
} catch (PrintException e1) {
logger.error(e1);
}
Michael Kerschbaum
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]