Printer, PrinterData and PrintDialog are three main classes related to Printing.
Printer descends from Device.
You can create a graphical context from it and draw on the graphical context.
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.printing.Printer;
public class DrawTextToPrint {
public static void main(String[] args) {
Printer printer = new Printer();
if (printer.startJob("Printing . . .")) {
GC gc = new GC(printer);
if (printer.startPage()) {
gc.drawText("Hello, World!", 20, 20);
printer.endPage();
}
gc.dispose();
}
printer.dispose();
}
}