Skip to main content
JR Boulay
Community Expert
Community Expert
May 3, 2020
Question

Programatically import a set of attachments

  • May 3, 2020
  • 6 replies
  • 485 views

Hi experts

 

I know how to import an attachment via JavaScript, letting the user choose the file.

Know I want to import a set of files located in the same folder, the path of this folder is known and always the same. Only the quantity of files varies, and their names.

 

Can I use JavaScript to programatically import all files contained in a folder as attachments in a PDF?

This script will run from an Action in Acrobat Pro DC for Windows.

 

Thank you

This topic has been closed for replies.

6 replies

JR Boulay
Community Expert
JR BoulayCommunity ExpertAuthor
Community Expert
May 3, 2020
Ok I understood.
Thank you both
Acrobate du PDF, InDesigner et Photoshopographe
JR Boulay
Community Expert
JR BoulayCommunity ExpertAuthor
Community Expert
May 3, 2020

I'm not sure to undestand, what do you mean by "batch process"?

Isn't an Action a batch process?

 

The use of VB is excluded, I will not learn a new foreign language just for that 😉

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
May 3, 2020

Yes, for the purely JavaScript technique I mean Action. Which BTW is a very over used word. 

 

But for my technique that uses an external VB program, I'm talking about batch processing in the generic sense, not an Action, but rather the process of iterating over a group of files, as implemented through the VB program. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JR Boulay
Community Expert
JR BoulayCommunity ExpertAuthor
Community Expert
May 3, 2020

try67: This script will run from an Action in Acrobat Pro, so I didn't see any security issues. If needed the user can confirm the folder's path.

 

Thom : my idea was a loop inside the target folder to catch all files, would it be possible?

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
May 3, 2020
In that case you can do it, using the method described by Thom, but only if
the files are PDFs.
Thom Parker
Community Expert
Community Expert
May 3, 2020

Actually, you could do this with a batch process. The script would need a way to identify the target file. A global is good for this. Then the script imports each file in the batch to the target. I don't see any problems with this technique.  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
JR Boulay
Community Expert
JR BoulayCommunity ExpertAuthor
Community Expert
May 3, 2020

Thank you

 

Why is JavaScript so cruel? 😞

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
May 3, 2020

To protect the users from having a script being able to access all the files on their computer...

try67
Community Expert
Community Expert
May 3, 2020

No.