Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
What can you see in the attachments panel?
Copy link to clipboard
Copied
The files are visible in the attachment panel ...
Copy link to clipboard
Copied
Are this file attachments or comment attachments?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.