• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Script to print specific pages in a PDF

New Here ,
Dec 07, 2018 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!

TOPICS
Acrobat SDK and JavaScript

Views

1.8K

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
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 07, 2018 Dec 07, 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.

Likes

Translate

Translate
Community Expert ,
Dec 07, 2018 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 less 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
community guidelines
New Here ,
Dec 07, 2018 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
community guidelines
Community Beginner ,
Jun 19, 2019 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
community guidelines
Community Expert ,
Jun 19, 2019 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
community guidelines
Community Beginner ,
Jun 19, 2019 Jun 19, 2019

Copy link to clipboard

Copied

LATEST

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
community guidelines