Print Page | Close Window

XI Action - Print PDF to PDF

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
Printed Date: 08 Dec 2019 at 7:39pm
Software Version: Web Wiz Forums 11.10 -

Topic: XI Action - Print PDF to PDF
Posted By: Lawguy
Subject: XI Action - Print PDF to PDF
Date Posted: 21 Apr 2015 at 3:55am
I have a folder of PDFs to which I have applied Bates numbering.  I want to create an Action (Acrobat XI) that will print these PDFs with the Bates back to PDFs (maintaining same name - either overwrite or to a new folder) which has the effect of flattening the Bates into the resulting PDF.  I have seen JS "window.print()" which should open the Print dialog . . . but it doesn't.  The action would:
     Option: Select document(s) or folder (no problem with this)
     Prints PDFs to PDFs (this is the problem)
My default Printer is an HP so the question is whether I need to first set Print to PDF as the default and then run the Action or if within the Action there is JS that would trump my default with Print to PDF while the Action executes.

Still searching, but most JS on Print to PDF seems to relate to web pages.

Suggestions much appreciated.

Posted By: try67
Date Posted: 21 Apr 2015 at 10:34am
Very bad idea, and not technically possible with JS in Acrobat.
You should instead flatten the file, using this command for example:
Then just re-save it.

- Acrobat Expert - Contact me personally at
Check out my custom-made scripts website:

Posted By: Lawguy
Date Posted: 21 Apr 2015 at 3:57pm
I have attempted both:;

Neither burns the Bates number into a single layer.  After trying both JS the Bates is removable through
     Tools > Pages > Bates Numbering > Remove

Conversely, Print Dialog > Printer: Adobe PDF does burn it thus making it unremovable.


Thank you

Posted By: Lawguy
Date Posted: 24 Apr 2015 at 12:16am

I have the first part of my proposed Acrobat XI Action working, i.e., selecting to Print to PDF is resolved with the following code:

pp = this.getPrintParams();

pp.interactive = pp.constants.interactionLevel.automatic;

pp.printerName = "Adobe PDF";


However it prompts to save.  I want to have the save overwrite the original file (Yes, I am working from a copy, not the original).  How can I do a hard save, alternatively to direct the save to a different folder and then, as the action cycles through all documents, repeat?

This presents a secondary issue inherent in the Print-to-PDF . . . it creates a copy of the document.  I have tried to code the Action with a separate script, including some found by the last reply:



     this.closeDoc(true); [from a try67 post)

None work and the “this.closeDoc(true);” crashes 

What I am trying to do is to:

     Select document(s)

     Print to PDF

     Save the new PDF

     Clear created new PDF

     Cycle through the rest of the docs 

Any help will help.

Posted By: try67
Date Posted: 24 Apr 2015 at 9:03am
I told you, it's a bad idea. You can't save the file automatically like that.
You'll have to click Save manually for each file that you process...

You should instead looking into using a Preflight Profile to flatten the file, or something like that.

- Acrobat Expert - Contact me personally at
Check out my custom-made scripts website:

Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 -
Copyright ©2001-2017 Web Wiz Ltd. -