Script to print specific pages in a PDF

New Here ,
Dec 07, 2018

Copy link to clipboard

Copied

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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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 smaller than the "normal" numbers.

TOPICS
Acrobat SDK and JavaScript

Views

351

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Script to print specific pages in a PDF

New Here ,
Dec 07, 2018

Copy link to clipboard

Copied

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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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 smaller than the "normal" numbers.

TOPICS
Acrobat SDK and JavaScript

Views

352

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 07, 2018 0
Most Valuable Participant ,
Dec 07, 2018

Copy link to clipboard

Copied

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 smaller than the "normal" numbers.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 07, 2018 2
New Here ,
Dec 07, 2018

Copy link to clipboard

Copied

Works perfectly! Thank you so much!!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 07, 2018 0
Community Beginner ,
Jun 19, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 19, 2019 0
Most Valuable Participant ,
Jun 19, 2019

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 19, 2019 2
jsv1 LATEST
Community Beginner ,
Jun 19, 2019

Copy link to clipboard

Copied

Thanks for replying! I appreciate your help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jun 19, 2019 0