My program gives the user a print Dialogue like so:
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(MainLauncher.printer);
boolean ok = job.printDialog();
if (ok) {
try {
job.print();
} catch (PrinterException ex) {
System.out.println("Printer Failed to Print.");
}
}
Which gives them this window:
My question is: How do I set all the fields in "Margins" to be 0 by default?
I'm on Linux, in case that makes a difference.
I have tried setting the ImagableArea to be the size of the page in the Printer after the dialogue is finished like so:
public int print(Graphics g, PageFormat pf, int page)
throws PrinterException {
double pageWidth = pf.getPaper().getWidth();
double pageHeight = pf.getPaper().getHeight();
Paper paper = new Paper();
paper.setImageableArea(0, 0, pageWidth, pageHeight);
pf.setPaper(paper);
but that just positions the images and writing I'm printing as if there were no Margin and then cutting out everything in the margin.
I've been trawling through the JavaDocs for hours and it's driving me bonkers. Any help would be much appreciated