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

Printing using javascript based on pages in the field

New Here ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

Greeting All,

 

I'm currently trying to create a print button using JavaScript that prints out pages given the page numbers in a field value. 

Example:

Field Value: "6, 7, 15, 30, 32, ..." - This field value changes based on the user answers in previous fields. 

Print button prints pages 6, 7, 15, 30, 32, ...

 

Currently copying the field, to the print dialogue box manually, but wondering if there there was way to do all this in 1 button. Any advice is greatly appreciated. 

 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

313

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 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

LATEST

You can achieve it using this script:

 

var pagesString = this.getField("Pages").valueAsString.replace(/\s/g, "");
var pages = pagesString.split(",");
var pagesRanges = [];
for (var i in pages) {
	pagesRanges.push([Number(pages[i])-1, Number(pages[i])-1]);
}
var pp = this.getPrintParams();
pp.printRange = pagesRanges;
this.print(pp); 

 

I assumed the field is called "Pages", since you didn't specify it...

Votes

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