Skip to main content
Participant
December 7, 2018
Answered

Script to print specific pages in a PDF

  • December 7, 2018
  • 1 reply
  • 5682 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
Community Expert
try67Community ExpertCorrect answer
Community 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.

Frady2Author
Participant
December 7, 2018

Works perfectly! Thank you so much!!