Skip to main content
New Participant
December 7, 2018
Answered

Script to print specific pages in a PDF

  • December 7, 2018
  • 1 reply
  • 5666 views

Is there a way to write a script that will allow a button to print specific pages when clicked? Noot consecutive pages, however. The user has to print out the application on page one, but may only need to print pages 3, 5 and 8 after that. I don't really know Java, so any help is greatly appreciated!

This topic has been closed for replies.
Correct answer try67

Yes, but it will only work in Reader (or Acrobat) versions 11 or higher.

The basic code to do it is:

 

var pp = this.getPrintParams();

var printRange = [];

printRange.push([0,0]); // print page 1

printRange.push([2,2]); // print page 3

printRange.push([4,4]); // print page 5

printRange.push([7,7]); // print page 8

pp.printRange = printRange;

this.print(pp);

 

Note the page numbers in the code (JavaScript, by the way, not Java) are zero-based, so one less than the "normal" numbers.

1 reply

try67
try67Correct answer
Adobe Expert
December 7, 2018

Yes, but it will only work in Reader (or Acrobat) versions 11 or higher.

The basic code to do it is:

 

var pp = this.getPrintParams();

var printRange = [];

printRange.push([0,0]); // print page 1

printRange.push([2,2]); // print page 3

printRange.push([4,4]); // print page 5

printRange.push([7,7]); // print page 8

pp.printRange = printRange;

this.print(pp);

 

Note the page numbers in the code (JavaScript, by the way, not Java) are zero-based, so one less than the "normal" numbers.

Inspiring
June 19, 2019

Apologies for reviving an old thread, but I couldn't find any info about my issue. Your solution above worked great when users downloaded a copy of the PDF to their desktop, but it didn't work well when using the web approach of Acrobat reader (the view you get when you open a PDF in a browser). I noticed the buttons I had created weren't even clickable in the web view, so I'm not sure what's going on. If you could point me in the right direction, I'd greatly appreciate it.

try67
Adobe Expert
June 19, 2019

They are most likely not using the Reader plugin, since it's no longer compatible with most browsers. Instruct them to save the file locally and then open it in Reader for it to work correctly.