import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.printing.Printer;
import org.eclipse.swt.printing.PrinterData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class PrinterDPI{
public static void main (String [] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.open ();
PrinterData data = Printer.getDefaultPrinterData();
if (data == null) {
return;
}
Printer printer = new Printer(data);
if (printer.startJob("SWT Printing Snippet")) {
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
Point dpi = printer.getDPI();
System.out.println(trim);
System.out.println(dpi);
printer.endJob();
}
printer.dispose();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose();
}
}