Unable to Automatically Set Minimum Margins on Print
807591May 12 2008 — edited May 13 2008I am having a problem determining the minimum margins automatically for printers. The following code works on Windows:
{color:#800000}printJob = PrinterJob.getPrinterJob(); // get a printing object
pageFormat = printJob.defaultPage(); // get the page format
printer = printJob.getPrintService(); // get the default printer;
Paper paper = pageFormat.getPaper();
paper.setImageableArea(0, 0, pageFormat.getWidth(), pageFormat.getHeight()); // set imageable area to size of paper
pageFormat.setPaper(paper);
pageFormat = printJob.validatePage(pageFormat); // should reset imageable area to use minimum margins for the printer{color}
On Linux, using CUPS and Foomatic, the imageable area is not reset to use minimum margins; the imageable area remains set to the full size of the paper.
I used alignmargins to set the minimum margins in the PPD file for the printer, but this had no effect.
Is there a programatic way that I can determine the minimum margins for CUPS?