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 Kerschbaum Michael <m....@pke.at> on 2009/04/15 10:36:26 UTC

Special Printing Problem....

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: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: AW: Special Printing Problem....

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Hi Michael

On 15.04.2009 17:03:53 Kerschbaum Michael wrote:
<snip/>
> So then i tried writing a pdf and printing it (With the
> pdfTranscoder)... The Problem is, that i need some more information in
> the Printed document (Visible Layers, Date, who created that document,
> etc...) Don't know how to print that to the PDF File.

The PDF 1.5 optional content groups (which I understand are used to
identify layers in PDF) is not implemented, yet. We currently generate
PDF 1.4. As for document metadata, that could be relatively easy to add.
We already support embedding a full XMP metadata document from XSL-FO
into PDF. Doing the same from SVG wouldn't be a big deal.

But why would you need this with PDF if you don't have this available
when printing directly using Batik?

> How would you solve this problem ? Is there an easy way to get the
> opacity parts of the svg and replace them with the background, so that
> the output would be the same without opacity parts ? Or should I try to
> get the best trade of Resolution against this 60 Seconds ? or should i
> use pdf and think how to get addional information in it ?! Or ...?

If Thomas doesn't have any suggestions to improve the performance with
Batik alone, I only see the way via PDF.

<snip/>  



Jeremias Maerki


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


AW: Special Printing Problem....

Posted by Kerschbaum Michael <m....@pke.at>.
Hello,
 
Okay now i understand why the printer prints with high resolution when a
symbol or a line uses a fill-opacity. And with "normal" resolution when
the same svg is used without fill or stroke-opacity. Without that
knowledge it confused me a little.
 
I think you know much more internal things about rendering and Java2d
printing then i does... perhaps you can help me with my problem...
 
I have svg's that were generated from visio / microsoft svg export... i
have no possiblity to change them... not even in code (i tried to remove
the css style in code => fast but output changed => Symbol looks not
like the sould)... The resultion is not the most important point. The
most important point is that the svg must be printed within 60 Seconds
(F3003 Fire law in Austria) in A3 Color ! 
 
So i tried some other things. First was to use a BufferedImage write it
to PNG or GIF and print it. Was okay from the peformance but not very
nice. (would be okay but i thought there must be a better way) I mean
there is a possible trade of resolution against peformance to make it
okay for A3 Format.
 
So then i tried writing a pdf and printing it (With the
pdfTranscoder)... The Problem is, that i need some more information in
the Printed document (Visible Layers, Date, who created that document,
etc...) Don't know how to print that to the PDF File.
 
How would you solve this problem ? Is there an easy way to get the
opacity parts of the svg and replace them with the background, so that
the output would be the same without opacity parts ? Or should I try to
get the best trade of Resolution against this 60 Seconds ? or should i
use pdf and think how to get addional information in it ?! Or ...?

 

________________________________

Von: thomas.deweese@kodak.com [mailto:thomas.deweese@kodak.com] 
Gesendet: Mittwoch, 15. April 2009 15:45
An: batik-users@xmlgraphics.apache.org
Cc: batik-users@xmlgraphics.apache.org
Betreff: Re: Special Printing Problem....



Hi Kerschbaum,

"Kerschbaum Michael " <m....@pke.at> wrote on 04/15/2009 04:36:26
AM:

> 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)

   Since most printer languages don't support transparency natively, 
when you use that feature the Java engine needs to rasterize the
document 
and send it as a high resolution bitmap.  It does this in strips to
avoid 
excessive memory consumption (300*10*300*8.5*3 = ~23MB for US Letter). 

> 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...

   I don't think there is a better way unless you can afford to create 
a high resolution image. 


Re: Special Printing Problem....

Posted by th...@kodak.com.
Hi Kerschbaum,

"Kerschbaum Michael " <m....@pke.at> wrote on 04/15/2009 04:36:26 
AM:

> 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)

   Since most printer languages don't support transparency natively,
when you use that feature the Java engine needs to rasterize the document
and send it as a high resolution bitmap.  It does this in strips to avoid
excessive memory consumption (300*10*300*8.5*3 = ~23MB for US Letter).

> 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...

   I don't think there is a better way unless you can afford to create
a high resolution image.