Okay, so i just started working on a program that is supossed to print out its graphics. Mine is almost identical to the copyrighted one at Oracle located here http://docs.oracl
You need to make use of the Print Services API. This allows you to request certain properties for a PrintJob
, including the DPI.
This is a RELLAY basic example...
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(MediaSizeName.ISO_A4);
aset.add(new PrinterResolution(300, 300, PrinterResolution.DPI));
aset.add(new MediaPrintableArea(2, 2, 210 - 4, 297 - 4, MediaPrintableArea.MM));
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new PrintTask());
if (pj.printDialog(aset)) {
try {
pj.print(aset);
} catch (PrinterException ex) {
ex.printStackTrace();
}
}
Take a look at Working with Print Services and Attribues for more details