Skip to main content
noram65782408
Participant
Nov 19, 2019 5:18 PM UTC
Answered

Why does this javascript only work for 2 page documents? Trying to use it for a 3 page document

Hello,

 

IT guy for a small company here. I'm attempting to use a javascript file to print a number in the bottom corner of each page of a document, then incrementally for each copy of the document.

 

This JS works for 2 page documents but when I try to use the same code for a 3 page document to do the exact same thing it only prints the number on the first two pages

 

//-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//<AcroForm>
//<ACRO_source>Print:Annot1:MouseDown:Action1</ACRO_source>
//<ACRO_script>
/*********** belongs to: AcroForm:Print:Annot1:MouseDown:Action1 ***********/
var snum = app.response("Please Enter Starting Number","");
var f = this.getField("Serial Number");
f.value = snum;
var copies = app.response("Please Enter Number of Copies to Print","1");

if (copies == null || copies ==="" || copies === 0) {
txt = "No Copies Printed";
} else {
for (i=0; i < copies; i++) {
f.value = Number(f.value)+1;
var pp = this.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
this.print(pp);
}
}

//</ACRO_script>
//</AcroForm>

 

admittedly I have no experience with JS and this script was set up by the guy I replaced (whether he wrote it himself or found it online i'm unsure). 

This topic is closed to new replies. Start a new post to keep the conversation going.
Test Screen NameCorrect answer
Legend
Nov 19, 2019 10:12 PM UTC

The script doesn't add the field. So you have to put the field there yourself before running it. (My guess is someone did this for two pages, and it wasn't done when a third page was added).

6 replies

Test Screen NameCorrect answer
Legend
Nov 19, 2019 10:12 PM UTC

The script doesn't add the field. So you have to put the field there yourself before running it. (My guess is someone did this for two pages, and it wasn't done when a third page was added).

Translate
noram65782408
Participant
Nov 20, 2019 7:45 PM UTC

This was it! Thank you both so much. 

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 19, 2019 5:46 PM UTC

Does you add the field "Serial Number" on all 3 pages?

Translate
noram65782408
Participant
Nov 19, 2019 5:51 PM UTC

No, it doesn't. The number prints like normal on the first 2 pages but nothing at all on the 3rd. It doesn't actually print the string "serial number" anywhere on the sheets themselves, even on the first 2 pages. 

Translate
Bernd Alheit
Community Expert
Community Expert
Nov 19, 2019 6:11 PM UTC

I mean the field with this name.

Translate