xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Santos <aasan...@gmail.com>
Subject Problem when printing SVG
Date Tue, 27 Dec 2005 18:42:06 GMT
Hello,

I started using SVG and Batik only a few days ago, so this is all very
new stuff to me. I managed to work through the very basics of Batik to
display and manipulate SVGs using JSVGCanvas (what a great component!)
, but now I'm stuck in printing and the Transcoder API.

I first tried using the code found in Squiggle to print, but it took
an awful long time and was too resource-hungry. Besides that, it
cropped the lower-left corner of the image.

When I was browsing the list archives I found the following code,
which uses the Java printing API:

PrinterJob printerJob = PrinterJob.getPrinterJob();
PageFormat pageFormat = printerJob.defaultPage();
PrintTranscoder prm = new PrintTranscoder();
TranscoderInput ti = new TranscoderInput(svgCanvas.getSVGDocument());
prm.transcode(ti, null);

if (printerJob.printDialog()) {
   printerJob.setPrintable(prm, pageFormat);
   try {
      printerJob.print();
   } catch (Exception e) {
      System.out.println(e.getMessage());
   }
}

This code runs much quicker and also consumes much less resources than
the one from Squiggle, but unfurtunately it produces the same cropping
problem (although it crops only the left side of the image). It also
looks like it doesn't respect the page orientation defined in the
PrintOptions page. So, is there a "right" way of printing using Batik?
Or a preferred way, maybe?

I found several messages from people reporting the same sort of
problems, but none giving actual solutions to them. I realize I should
probably take some time to learn the inner workings of the Transcoder
API, but I would really appreciate some help from people who have
already been there.

BTW, I'm using Batik 1.6 (binary dist), JDK 1.4.2_08, Win2k SP4.

Many thanks in advance for any ideas,

Andre

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


Mime
View raw message