By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,740 Members | 844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,740 IT Pros & Developers. It's quick & easy.

very slow printing with java.​awt.​print.​PrinterJob

P: 14
Hi guys,

currently I'm encountering a strange behavior while using the PrinterJob class.

I've got a little program printing some pages. Most of the time the printer does its job as it should. But sometimes it takes minutes printing a page which was printed before in seconds.
It's absolutely random and not reproducible.

Following, the gist of the used code.
Where the Printable is a simple class implementing Printable and printing some text using Graphics.


Expand|Select|Wrap|Line Numbers
  1.     private void createPrinterJob(...) {
  2.         try {
  3.             Printable gp = new Printable( ... );
  4.             PrinterJob pjob = PrinterJob.getPrinterJob();
  5.             if (pjob.printDialog() == false) {
  6.                 return;
  7.             }
  8.             pjob.setPrintable(gp);
  9.             pjob.print();
  10.         } catch (PrinterException ex) {
  11.             ex.printStackTrace();
  12.         }
  13.     }
  14.  
I would be very glad if somebody ran across the same problem before and knows how to fix it.
Dec 22 '09 #1
Share this Question
Share on Google+
1 Reply


P: 1
The call to setPrintable() is the culprit. I have written several printing routines, and they all call setPrintable(). If you take that out, it will process very quickly (but will not print). I have not found any way to speed this up.
Jul 23 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.