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

[Acrobat Pro DC / Reader] Open all attachments using Javascript

Contributor ,
Jan 02, 2018 Jan 02, 2018

Hi,

With this post I would like to ask a question.

I need to create a PDF file containing 2 buttons.

The first button should attach (embed) files  to the PDF-file. This works very well using this script https://forums.adobe.com/thread/2097328

The second button needs to open all attachements. This doesn't work yet. I've tried using multiple pieces of code

This piece of code will throw an error (--> TypeError: Invalid argument type. cName ...)

this.exportDataObject({cName: "test.pdf", nLaunch: 2});

This code display's "No file attachments"

For some reason, dataObjects is always null

var d = this.dataObjects;

if ( d == null ) console.println("No file attachments");

else {

for ( var i = d.length - 1; i>=0; i--)

if ( d.name.indexOf("Untitled Object") != -1 ) break;

if ( i != -1 ) this.exportDataObject(d.name);

else console.println("No attachment was embedded by UI");

}

Does anyone have any idea on how I can fix this ?

Thanks

TOPICS
PDF forms
2.8K
Translate
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 ,
Jan 02, 2018 Jan 02, 2018

What can you see in the attachments panel?

Translate
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
Contributor ,
Jan 02, 2018 Jan 02, 2018

The files are visible in the attachment panel ...

Translate
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 ,
Jan 02, 2018 Jan 02, 2018

Are this file attachments or comment attachments?

Translate
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
Contributor ,
Jan 02, 2018 Jan 02, 2018

I did some more testing. When adding a document attachment manually, I'm able to open the file again using a script.

When adding a comment attachment manually, the script which opens the file, throws the same error (dataObjects ... null ...)

When viewing the import script, it seems that the files are embedded as comment attachment.

What is the best approach? Adding files as document or comment attachments? And how to open comment attachments ?

Thanks

Translate
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 ,
Jan 02, 2018 Jan 02, 2018
LATEST

If the file is going to be used in Reader then using comments is the only viable approach (unless you spend a lot of money on applying the File Attachment Rights to your files). Accessing these files is not done using the dataObjects property, though. They are annotations so you need to locate them using the getAnnots method. I don't believe you can launch them, though, as you can do with "normal" file attachments.

Translate
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