Copy link to clipboard
Copied
Hi
I need to create buttons that will print various ranges of pages in my document. that is, if someone wants to print out Chapter 3, there needs to be a button that, if clicked, prints just Chapter 3. I've done a bit of searching on the internet, and it seems like javascript is used for such tasks.
Unfortunately, I don't know javascript. I do see examples of scripts reported to cause Acrobat to print page ranges. But i don't know how to attach such scripts to a button. Is there a guide for beginners like me? In this case, I don't have time to learn javascript, I just need to implement it and change some variables (ie page ranges). Any thoughts?
Thanks in advance!
cheers,
kurt
Yes, you have to use a script. It's not too complicated, though. Here's the basic code you need:
var firstPage = 10;
var lastPage = 15;
this.print({nStart: firstPage-1, nEnd: lastPage-1});
The code above will open the Print dialog with pages 10-15 pre-selected.
To attach it to a button field go to Prepare Form mode, right-click the button, select Properties, Actions, then create a new Mouse Up action with the "Run a JavaScript" command and paste the code into the editor window that will open
...Copy link to clipboard
Copied
Yes, you have to use a script. It's not too complicated, though. Here's the basic code you need:
var firstPage = 10;
var lastPage = 15;
this.print({nStart: firstPage-1, nEnd: lastPage-1});
The code above will open the Print dialog with pages 10-15 pre-selected.
To attach it to a button field go to Prepare Form mode, right-click the button, select Properties, Actions, then create a new Mouse Up action with the "Run a JavaScript" command and paste the code into the editor window that will open. That's it.
Copy link to clipboard
Copied
try67, this is exactly what I was looking for. Thanks!!!
Copy link to clipboard
Copied
Is there a modification I can add to include an additional, single page? ie. Print pages 5-9 PLUS page 23?
Copy link to clipboard
Copied
That requires a more complex script. Try this:
var pp = this.getPrintParams();
pp.printRange = [[4,8], [22,22]];
this.print(pp);
Copy link to clipboard
Copied
Thank you again — perfect! And apologies for the extra work. . .I saw your response to the same question under "Javascript - Control Whether Page Prints?"