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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daschicken
    New Member
    • Jan 2008
    • 14

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

    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.


    Code:
        private void createPrinterJob(...) {
            try {
                Printable gp = new Printable( ... );
                PrinterJob pjob = PrinterJob.getPrinterJob();
                if (pjob.printDialog() == false) {
                    return;
                }
                pjob.setPrintable(gp);
                pjob.print();
            } catch (PrinterException ex) {
                ex.printStackTrace();
            }
        }
    I would be very glad if somebody ran across the same problem before and knows how to fix it.
  • Bob Sigmon
    New Member
    • Jul 2010
    • 1

    #2
    One call is slow

    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.

    Comment

    Working...