Skip to main content
Inspiring
June 27, 2024
Answered

Print pages to PDF

  • June 27, 2024
  • 2 replies
  • 716 views

I have a pdf document with 30 pages.  I would like to print pages 2 and 3 to the Adobe PDF printer using javascript.  I tried the following javascript code in a button on page 2 but it does not work:

 

var pp = this.getPrintParams();
pp.printerName = "Adobe PDF";
pp.pageHandling = pp.constants.handling.fit;
this.print(pp);
pp.this.print(false, this.pageNum,(this.pageNum+1));

 

I would like the two pages to print without bringing up the print menu box.  Any help would be appreciated.  Thanks.

This topic has been closed for replies.
Correct answer Thom Parker

You can print to postscript, then open the postscript file in Acrobat to convert it to PDF.  This will flatten the PDF. 

See this entry in the Acrobat JavaScript Reference:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#id799

 

Also, if the PrintParams object is used, then all printing parameters must be set in the PrintParams object.  The PrintParams object cannot be mixed with other print function inputs. 

 

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
June 27, 2024

You can print to postscript, then open the postscript file in Acrobat to convert it to PDF.  This will flatten the PDF. 

See this entry in the Acrobat JavaScript Reference:

https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#id799

 

Also, if the PrintParams object is used, then all printing parameters must be set in the PrintParams object.  The PrintParams object cannot be mixed with other print function inputs. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
June 27, 2024

Not possible. Instead, you should use the extractPages method. That will allow you to specify the path of the new file.