Dec 08

The PrinterJob class supports displaying a print dialog for the user to use to select printer settings as shown in the following example.

PrinterJob job = PrinterJob.getPrinterJob();
PageFormat format = job.defaultPage();

// Display print dialog

if (job.printDialog()) {

    // We can now check the settings specified by user

    PrintService selectedPrinter = job.getPrintService();

    // or print something using the settings

    job.setPrintable(myPrintable, job.defaultPage());

written by objects \\ tags: , , ,

Oct 03

The Desktop class was added in Java 6 to handle launching associated applications on the native desktop.

Following shows how to print a file with the associated native printing facility.

File file = new File("/tmp/file.txt");
Desktop desktop = Desktop.getDesktop();

written by objects \\ tags: , , , ,