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 = color.black;
btn.buttonSetCaption(">");
btn.lineWidth = 1;
btn.setAction("MouseUp","this.pageNum++;");
btn.delay=true;
btn.highlight='push';
btn.fillColor=color.black;
btn.delay=false;
btn.textColor = color.white;
Any thoughts?
sj
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 = color.black; // border color;
btn.lineWidth = 1; // border width;
btn.fillColor=color.black; // 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
AddNextPage(aMyPages);
George Kaiser