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

Programatically import a set of attachments

Community Expert ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

293

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

No.

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

Thank you

 

Why is JavaScript so cruel? 😞

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

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

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

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?

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

In that case you can do it, using the method described by Thom, but only if
the files are PDFs.

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

Hi JR, Unfortunatley there is no general file system access from the Acrobat scripting model.  So the only way to process an arbitrary set of files is through a batch process. 

 

Another solution that I have used frequently is to create a VB application that uses the IAC to preform a kind of psuedo-batch operation. But this is a Windows only solution, and the batch script is much easier to implement. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

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 😉

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

LATEST
Ok I understood.
Thank you both

Votes

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