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

Use javascript to handle files created by batch saveAs()?

New Here ,
Jul 13, 2019 Jul 13, 2019

Copy link to clipboard

Copied

Hi,

I have succesfully written a script which uses a dynamic stamp to set an "Exhibit 1, 2, 3..." stamp on single PDFs based on the filename (the source files are labeled 001-..., 002-..., etc.). The script uses saveAs() to save the newly stamped files with names P001-....pdf, P002-...pdf in the same folder than the source.

I can now run an action which runs the script on multiple files.

What I need to do next in the workflow is combine all the newly created, stamped files in a single (optimised) PDF file, which I do manually from Windows Explorer (select - right click - combine, option "reduce file size"). The fact of having a bookmark corresponding to each file is a plus.

I would like to further automate this as part of my action (or of a folder level script).

Leaving aside the optimisation question (which I understand I could solve by using doc.preflight), I don't understand how I am supposed to use, from the same script or action, the files I have generated in order to combine them. I went through the Acrobat Javascript reference and don't find anything clearly useful (storing the newly created filenames/paths as global variables and use insertPages afterwards? have all the newly created files open in Acrobat and use the activeDocs property in conjunction with insertPages?).

The obvious problem I encounter is that the script executed through the action runs on every single file sequentially whereas I need part of the automation to be ran on each file before getting to the next step of combining the results.

So the process is:

I have files 001-file1.pdf, 002-secondexample.pdf, 003-thirdfile.pdf.

The existing script yields P001-file1.pdf, P002-secondexample.pdf, P003-thirdfile.pdf.

And I need P001-file1.pdf, P002-secondexample.pdf, P003-thirdfile.pdf to be combined in a single, possibly optimised, possibly bookmarked PDF.

Any suggestion or hint towards the right direction would be very appreciated. Thank you very much in advance.
TOPICS
Acrobat SDK and JavaScript

Views

178

Likes

Translate

Translate

Report

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
New Here ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

Any hint or idea, or the definite conclusion that it is impossible, would be greatly appreciated... thank you in advance!

Likes

Translate

Translate

Report

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 ,
Aug 06, 2019 Aug 06, 2019

Copy link to clipboard

Copied

So you want to combine all the files in the folder? If so, it can be done using a combination of an Action (which collects the file paths) and a script which combines them.

In fact, I've developed a (paid-for) tool that does just that. You can find it here: Custom-made Adobe Scripts: Acrobat -- Batch Combine All PDF Files in a Folder

Likes

Translate

Translate

Report

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
New Here ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

Thank you, this seems to be a useful piece of the puzzle, but if I understand correctly the script does not touch the content of the files prior to combining them. I am looking for a solution to execute a script on each file (which changes its contents) prior to combining them, and to have this process included in a single action/script/command. Does it seem feasible?

Likes

Translate

Translate

Report

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 ,
Aug 07, 2019 Aug 07, 2019

Copy link to clipboard

Copied

LATEST

You can change the Action to make the edits you need, but it still has to be a two-step process.

Likes

Translate

Translate

Report

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