Copy link to clipboard
Copied
I have 2 printers. One is specially bought for shipping labels.
All my shipping labels are generated pdf files with smaller dimensions (153,8 x 106,2 mm, let's say A6 format).
As I use the other printer on the same machine (iMac) for all "normal" A4 pdf documents, I always have to be careful not to waste shipping labels, using Acrobat Reader DC taking into account the last chosen printer will be preselected in the print dialog box. This, of course, is the normal behavior of Acrobat Reader.
My Acrobat Reader DC:
Architecture: x86_64
Build: 18.9.20050.254034
AGM: 4.30.72
CoolType: 5.14.5
JP2K: 1.2.2.39492
My iMac:
OS X El Capitan version 10.11.6
The next script normally should launch the print dialog box with the best printer preselected (in function of the paper size).
// start script
var defaultPrinter = (new String("DYMO LabelWriter 4XL"));
var largeFormatPrinter = (new String("Brother HL-L2360D series"));
var pageBox = this.getPageBox();
var pageWidth = pageBox[2]/2.83;
var pageHeight = pageBox[1]/2.83;
var selectedPrinterName;
if (pageWidth<160 && pageHeight<108) {
selectedPrinterName = ""+defaultPrinter;
}
else {
selectedPrinterName = ""+largeFormatPrinter;
}
var pp = this.getPrintParams();
pp.printerName = selectedPrinterName;
app.alert("The chosen printer is " + pp.printerName, 3);
this.print(pp);
// end script
Problem: Even if the correct printer is displayed in the alert (defined by the page dimensions), the preselected printer in the print dialog box is not always the right printer. It still will be the last used one: the normal behavior of Acrobat Reader. Somebody told me it was really working on his Windows machine. Is there something I'll have to configure in the Acrobat Reader program preferences or something else I'll have to take into account on a iMac machine?
Copy link to clipboard
Copied
The printer UI is not linked to the JavaScript objects in a direct manner. One can set the printer name in the Print Params object but then one needs to the document object print method to print using the print params
Copy link to clipboard
Copied
Thats exactly what I'm doing, right?
I call the function by a self created menu:
app.addMenuItem({ cName: "MyFilename", cUser: "Print by page size", cParent: "File", nPos: "Print", cExec: "myOwnFunction()", cEnable: "event.rc = (event.target != null);"});
Copy link to clipboard
Copied
Hi Gkaiseril,
isn’t the call of the last function in this code this.print(pp) doing this?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now