Skip to main content
Known Participant
November 4, 2019
Answered

Print pages with JavaScript

  • November 4, 2019
  • 2 replies
  • 16467 views

Hi everyone, I have a question. I have the script, that sorting pages depending size and i need to write a script to print pages - on different printers, depending on the page size (for example: A1, A2 etc.). May be somebody met this problem? 

 

my script: 

https://scrimba.com/c/c7PwMkua

This topic has been closed for replies.
Correct answer try67

Are there in Acrobat JS Api command  - confirm() - like in native JS?


You can use the alert method for that. For example:

 

if (app.alert("Do you want to print the file now?",2,2)==4) {

    this.print();

}

2 replies

swapnilsrivastava
Community Manager
Community Manager
November 5, 2019

Hi There,

 

Thanks for reporting this.

We provide a JavaScript tool inside Adobe Acrobat, which can be used to any additional content like page number on the PDF file.

 

Regards,

Swapnil Srivastava

Known Participant
November 5, 2019

Hi there. How can I bring up a modal window in Acrobat? I want that after sorting by page size, a modal window appears with a print request, if agreed, it should call the printer and plotter, depending on the size of the sheet. Somebody can advice me?

Known Participant
November 5, 2019

Are there in Acrobat JS Api command  - confirm() - like in native JS?

try67
Community Expert
Community Expert
November 4, 2019

Look into the print method of the Document object and especially into the various properties of the PrintParams object.

Here's a simple example of how to print pages 1-5 to one printer and pages 6-10 to another:

 

 

var pp = this.getPrintParams();
pp.printerName = "My Printer 1";
pp.firstPage = 0;
pp.lastPage = 4;
this.print(pp);
pp.printerName = "My Printer 2";
pp.firstPage = 5;
pp.lastPage = 9;
this.print(pp);

 

Edit: Small mistake fixed in the code.

 

Known Participant
November 4, 2019

Thank you so much, I'll try it!! 😉