These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Placing Fields on multiple pages

Registered: Oct 15 2008
Posts: 52

Is there a way to indicate what page numbers you want the fields to fall on? I want to repeat the same script on pages 2, 4, even pages. But, I am currently just repeating the below script multiple times...and it's getting long.
My current script looks like this:
var btn=this.addField("Next Page","button",
0, [438,61,460,37]);
btn.userName = "Next Page.";
btn.borderStyle = border.b;
btn.strokeColor =;
btn.lineWidth = 1;
btn.textColor = color.white;
Any thoughts?

My Product Information:
Acrobat Pro Extended 9.4.3, Macintosh
Registered: Feb 23 2006
Posts: 4307
Have you looked at the parameters for the 'addField' method?

One of the parameters is a page number, the 3rd required parameter or the named parameter "nPageNum", which can be a variable. The page number is a zero based value so the first page of a PDF is 0 but displays as 1.

You can make an array of page numbers upon which you want the field to be added and then use a control loop to precess the script for each page. You also might want to create a function to add the button with a variable page number.

function AddNextPage(aPageNum) {
var btn;
for(i = 0; i < aPageNum.length; i++) {
// add field to page
btn = this.addField({cName:"Next_Page",
cFieldType: "button",
nPageNum: aPageNum[i],
oCoords: [438,61,460,37] });
btn.delay=true; // delay redraw
btn.userName = "Next Page."; // user name;
btn.borderStyle = border.b; // border;
btn.strokeColor =; // border color;
btn.lineWidth = 1; // border width;; // fill color;
btn.textColor = color.white; // text color;
btn.buttonSetCaption(">"); // caption;
btn.setAction("MouseUp","this.pageNum++;"); // action;
btn.highlight='push'; // highlight;
btn.delay=false; // redraw;
} // end page loop
return; // exit function;
} // end function AddNextPage

// define array or page numbers to add button to
var aMyPages =(1,3,5,6,7,9); // even displayed pages;
// add field to pages

George Kaiser