Copy link to clipboard
Copied
Hello,
I have a print button with the following script:
this.print({bUI: true, nStart: this.pageNum, nEnd: 1,bShrinkToFit: true});
I would like to also add the following features:
- hardcode: 2 sided printing or 1 sided printing.
- specify the number of copies.
- specify collate on or off
Thank you!
Copy link to clipboard
Copied
It's all documented where we mentioned, but here you go:
var pp = this.getPrintParams();
pp.firstPage = 1;
pp.lastPage = 3;
pp.NumCopies = 3;
pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge;
pp.pageHandling = pp.constants.handling.fit;
this.print(pp);
Copy link to clipboard
Copied
Additionally, Is there a way to send the print to the default printer without bringing up the print dialogue box?
^ If yes, I would also like to have the script produce a pop-up window confirming that printing is in progress "Document sent to printer".
Copy link to clipboard
Copied
Do you have the JavaScript API document?
Copy link to clipboard
Copied
Read the documentation of the PrintParams object. Most of what you asked for is possible.
Copy link to clipboard
Copied
Do you have the JavaScript API document?
Copy link to clipboard
Copied
To be clear, I don't know any Java Script. But I can figure things out when I observe/play with a code...
I had searched the forum for the features I was asking for and found codes but have not been able to incorporate it into one single working code:
this.print({bUI: true, nStart: this.pageNum, nEnd: 5,bShrinkToFit: true});
var pp = this.getPrintParams(); //pp.NumCopies = 3; //pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge; this.print(pp);
^ For example, when I add the 2nd half of the code, the print button will bring up the print dialogue, but it will only load the code from the first line, then when I click cancel "cancel" the dialogue will reload, but the preferences from the first line are no longer applied (e.g. page range, shrink to fit), but now has preferences from second code. I have played with this code for hours trying to get it to work, but can't. Can someone please post the correct full code that specifies the additional settings:
- 2 sided printing or 1 sided printing.
- specify the number of copies.
- specify collate on or off
Thank you
Copy link to clipboard
Copied
Use only the second code, and remove the "//" parts from it, as that comments out the code following it.
So your code would be:
var pp = this.getPrintParams();
pp.NumCopies = 3;
pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge;
this.print(pp);
I don't think it's possible to set the collate option, though.
Copy link to clipboard
Copied
Thank for the quick reply. the code you gave doesn't include some of the things I need, such as page start and end parameters, and need it to "fit" to page instead of shrink/actual size when printing.
Copy link to clipboard
Copied
can you provide a complete code that also incorporates the page start and end and "fit to page" settings in one single code?
Copy link to clipboard
Copied
It's all documented where we mentioned, but here you go:
var pp = this.getPrintParams();
pp.firstPage = 1;
pp.lastPage = 3;
pp.NumCopies = 3;
pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge;
pp.pageHandling = pp.constants.handling.fit;
this.print(pp);
Copy link to clipboard
Copied
These parameters can be easily adjusted for each document in the "Document Properties" (File menu).
The Action Wizard allows you to apply these settings to several documents.
Copy link to clipboard
Copied
@try67, you're my hero! Everything in the code works, except the duplex setting. That might just because of my printer drivers.. will test on different computer/printer.
@JR_Boulay,
thanks for that. however, that route won't work as this is a large PDF file, containing many different documents, each with different page numbers. So there is a different print button on the first page of each document that dictates the printing rules. Some are duplex printing, some are not.. some are single copy some are more, etc.
Copy link to clipboard
Copied
Try67, I noticed the code does not specify collate on or off.
Is it possible to specify that via Javascript?
Copy link to clipboard
Copied
I did not see an option to specify that setting, no.