Copy link to clipboard
Copied
JavaScript slently print HELP
Translate google
I have 2 printers, print PDF file size is 430mm * 310mm, and need to be marked with 0001-00100 each number, you can manually double-sided printing on the 450mm * 320mm, but I and JavaScript silently print, only print Double sided A4 size paper. Plus "pp.flags | = fv.setPageSize;" can print out the A3 size red, but not the first time to print the parameters to print correctly. That is, the last print setting parameter is not recorded when silently printing.
The code is as follows:
var l= 4;
var s = 5;
var p=0;
for(var i = 1; i <= s;i++) {
this.getField("Text1").value=pad(i,l);
this.print({bUI: false, bSilent: false, bShrinkToFit: false});
}
function pad(num, n) {
var len = num.toString().length;
while(len < n) {
num = "0" + num;
len++;
}
return num;
}
The following is another code is also printed without the correct results.
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
pp.pageHandling = pp.constants.handling.none;
var fv = pp.constants.flagValues;
pp.flags |= fv.setPageSize;
this.print(pp);
Copy link to clipboard
Copied
From what context are you executing this code?
Copy link to clipboard
Copied
Folders are executed.
The file is generated .JS file, added to the custom menu, the code can be executed correctly but not the result I want.
This is the beginning of the code.
app.addMenuItem({
cName: "Number", cParent: "Tools",
cExec: "AutoNumber();",
cEnable: "event.rc= (event.target != null);" });
function AutoNumber()
{
}