Category Archives: PrinterJob

Showing a Print Dialog



Introduction

Showing a print dialog is a common task for every print job. This example shows how to do it:

PrinterJob pjob = PrinterJob.getPrinterJob();
PageFormat pf = pjob.defaultPage();
pjob.setPrintable(new PrintableClass(), pf);
try {
    if (pjob.printDialog()) {
        pjob.print();
    }
} catch (PrinterException e) {
}