Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thank you so much, I'll try it!! 😉
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Are there in Acrobat JS Api command - confirm() - like in native JS?
Copy link to clipboard
Copied
Do you have the JavaScript API Reference? It shows all classes and methods available. Specifically, app.alert, which is a whole lot easier than using Dialog.
Copy link to clipboard
Copied
Thanks, Yes dude I have a small JS Api reference, but i can't to find it. I'm junior in Adobe, therefore have many problem, but i'm trying. Thank you
Copy link to clipboard
Copied
The JavaScript API Reference isn't small - it's nearly 800 pages. You need it though. Here is a link to an old API Reference, but not much has changed lately... https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_reference.pdf
Copy link to clipboard
Copied
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();
}
Copy link to clipboard
Copied
Yes dude, it works 🙂 I wrote:
const requ = app.alert('Send to print?', 2, 2);
if(requ === 4){
const pp = this.getPrintParams();
pp.printerName = 'Printer1';
this.print(pp);
}
Copy link to clipboard
Copied
Hello, can i do so?
/* code for print pages:
acp - is the array of objects, inside there are own width and height of every page in document */
if(app.alert('Do you want to print the files now?', 2, 2) == 4) {
const pp1 = this.getPrintParams(),
pp2 = this.getPrintParams();
pp1.printerName = 'Printer';
pp2.printerName = 'Plotter';
for(var item = 0; item < acp.length; item++){
if(acp[item].width <= 420 && acp[item].height <= 297){
this.print(pp1);
}
if(acp[item].width >= 594 && acp[item].height >= 420){
this.print(pp2);
}
}
}
Copy link to clipboard
Copied
- What is the "acp" array?
- Why are you using const instead of var?
Copy link to clipboard
Copied
Inside the acp array are objects of width and height pages. I usually use ES6, it will be problem in Adobe?
Copy link to clipboard
Copied
Yes. The "const" keyword defines a constant, which means you can't change it.
Run this code and see what the results are:
const a = 5; a = 4; console.println(a);
And then run this code:
var b = 5; b = 4; console.println(b);
Copy link to clipboard
Copied
Also, you have to define the firstPage and lastPage parameters in the PrintParams object. If you don't, it will print the entire file by default.
Copy link to clipboard
Copied
I understand, thank you. But i need to print all the pages from the document, only they must be sorted. My code is sorting, i sent only a part of the code that will distribute the sorted pages to the printer and plotter. I'll change the const on var, but basically my code is working correctly?
Copy link to clipboard
Copied
If your code is working correctly, do you still have a question for us, please?
Copy link to clipboard
Copied
yes there will be questions, why do you ask?
Copy link to clipboard
Copied
I don't think your code is correct, as what you're doing in it doesn't make sense, but if you're happy with the result that's fine.
Copy link to clipboard
Copied
Want you print all pages on the printer and plotter?
Copy link to clipboard
Copied
Yes, I want to make automatically process, after sort the pages i'll get modal window - print or not, when the user click - Yes - automatically print pages on plotter and printer depending sizes... Sorry for my english
Copy link to clipboard
Copied
So, what is your question. What does your code do now, please post the CURRENT code and tell us what it does, what you want it to do, and what is stopping you from doing this. Please never post code that is not the current exact code you are asking us to discuss, this wastes everyone's time.
Copy link to clipboard
Copied
Read the reply of try67:
Also, you have to define the firstPage and lastPage parameters in the PrintParams object. If you don't, it will print the entire file by default.
Copy link to clipboard
Copied
Look into the "Dialog" class. Complicated to use, but powerful.

