Skip to main content
Inspiring
December 9, 2023
Question

code to print

  • December 9, 2023
  • 1 reply
  • 3946 views

hi
I created the attached code to print the 181 pages of a pdf file
In fields
this.getField("start of mandate").value;
this.getField("end of mandate").value;
this.getField("privacy start").value;

etc.........
I inserted this function in the script of the field event.value=event.target.page; which returns the page number where the fields are located.

when in the drop-down menu of the "OPTIONS" field I select "PRINT BANK" when the file print arrives at this code:
var pp = this.getPrintParams();
pp.colorOverride = st1;
pp.pageHandling = st2;
if (/1/.test(a1))pp.printRange=[[s38,s41],[s45,s45],[s47,s47],[s51,s52]];
if (/2/.test(a1))pp.printRange=[[s38,s42],[s45,s48],[s51,s52]];
if (/3/.test(a1))pp.printRange=[[s38,s43],[s45,s49],[s51,s52]];
if (/4/.test(a1))pp.printRange=[[s38,s52]];
pp.NumCopies=1;
pp.DuplexType =1;
pp.printerName = st3;
pp.interactive = st4;
this.print(pp);}
the pages indicated in the code are not printed, but all 181 pages of the pdf file are printed
However, when I select the other items in the drop-down menu of the "OPTIONS" field, the code described above works perfectly.
I can't figure out where I made the mistake.
Please, can anyone help me fix my code?
Thank you very much for your attention

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 9, 2023

For starters, your code is badly formatted and is missing at least one closing curly bracket.

Beyond that, without seeing the actual file it's very difficult to help you, because we don't know what are the values of the fields you're using for the page numbers...

try67
Community Expert
Community Expert
December 9, 2023

Also, constants are not strings, so remove the quotes around them.

ENE5CD9Author
Inspiring
December 9, 2023

The curly bracket is not there because I didn't copy and paste it into the text file
The file is approximately 37 MB
I removed the quotes from the constants, but this error message appears on the console
TypeError: pp is undefined
65:Console:Exec