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

Checkbox that will print specific pages Javascript?

viega
Registered: Sep 23 2010
Posts: 2
Answered

Hello,
I have a multiple page PDF that I have made into a form. Depending on which check box people choose on the second page, I only want certain pages after that to print when they finish the form.
For example:
If they check the box for "movies" it will print pages 1-2 and 5-7 only.
If they check "food" it will only print 1-2 and 8-10 only.
 
I'm sure there is probably some Java Script involved, but I'm not sure.
 
Your help is much appreciated! Thanks in advance!

Nicole

My Product Information:
Acrobat Pro 9.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2399
You can only enforce that if the file is printed through a button you created, not if the file is printed using the built-in command.
To do so use the print method of the Document object.
For example:
if (this.getField("movies").value == "Yes") {this.print({bUI:false, nStart:0, nEnd:1, bSilent: true});this.print({bUI:false, nStart:4, nEnd:6, bSilent: true});}

See the reference files for more info.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

viega
Registered: Sep 23 2010
Posts: 2
Thank you very much! This script works great! I do have an additional question ...

I realized that people may select multiple boxes ... with the script above, I get multiple copies of pages 1-2 printing for each checked box. (Only one copy of pgs 1-2 is needed no matter how many boxes they check).
Can the script be modified so that if they click multiple boxes, it doesn't keep repeating printing pages 1-2?

Can it be two separate scripts? For example one script that if any check boxes are selected it prints 1-2 and then if "movies" is checked it will also print 5-7?

I wasn't sure if you could list multiple "getField"s in the same script or if each one has to be listed separately.

I did try several things, but when I printed, I got nothing, or multiples of pages 1-2.

Thanks again for your excellent help!

Nicole