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

Print Button

Explorer ,
Jan 26, 2020 Jan 26, 2020

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!

TOPICS
How to , PDF forms , Print and prepress
2.5K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Jan 27, 2020 Jan 27, 2020

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); 

View solution in original post

Translate
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
Explorer ,
Jan 26, 2020 Jan 26, 2020

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".

Translate
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
LEGEND ,
Jan 26, 2020 Jan 26, 2020

Do you have the JavaScript API document?

Translate
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 ,
Jan 26, 2020 Jan 26, 2020

Read the documentation of the PrintParams object. Most of what you asked for is possible.

Translate
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 ,
Jan 26, 2020 Jan 26, 2020

Do you have the JavaScript API document?

==> https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/Acro12_MasterBook/JS_API_AcroJS/Pr...


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Explorer ,
Jan 26, 2020 Jan 26, 2020

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

Translate
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 ,
Jan 26, 2020 Jan 26, 2020

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.

Translate
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
Explorer ,
Jan 26, 2020 Jan 26, 2020

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.

Translate
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
Explorer ,
Jan 26, 2020 Jan 26, 2020

can you provide a complete code that also incorporates the page start and end and "fit to page" settings in one single code?

Translate
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 ,
Jan 27, 2020 Jan 27, 2020

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); 
Translate
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 ,
Jan 27, 2020 Jan 27, 2020

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.

 

Capture_041.png


Acrobate du PDF, InDesigner et Photoshopographe
Translate
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
Explorer ,
Jan 27, 2020 Jan 27, 2020

@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.

 

Translate
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
Explorer ,
Jan 27, 2020 Jan 27, 2020

Try67, I noticed the code does not specify collate on or off. 

Is it possible to specify that via Javascript?

Translate
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 ,
Jan 27, 2020 Jan 27, 2020
LATEST

I did not see an option to specify that setting, no.

Translate
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