Java Tutorial/SWT/PrinterData
17. The PrinterData object contains information about current printing job.
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.printing.Printer;
import org.eclipse.swt.printing.PrinterData;
public class PrinterDataFromPrinter {
public static void main(String[] args) {
Printer printer = new Printer();
PrinterData printerData = printer.getPrinterData();
System.out.println(printerData.driver);
if (printer.startJob("Printing . . .")) {
GC gc = new GC(printer);
if (printer.startPage()) {
gc.drawText("Hello, World!", 20, 20);
printer.endPage();
}
gc.dispose();
}
printer.dispose();
}
}