Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list

List of attachments in PDF

Avatar

Not applicable
How can we use javascript to get a list of attachments currently attached to our PDF document?



Thanks in advance,

Ali.
4 Replies

Avatar

Level 5
Loop throught the dataObjects.



// List ANY ATTACHMENTS

var d = event.target.dataObjects;

if (d != null)

for (var i = 0; i < d.length; i++)

{

console.println("Data Object[" + i + "]=" + d[i].name);

}



Mark

Avatar

Not applicable
Thanks Mark for the tip.

I am using LiveCycle Designer ES to make the form, using javascript to get my functionality.



I tried to access the attachment names with your advice, by looping through the dataObjects. But it always gives the name "Untitled Object" no matter which document I attach.



I have tried to find resources to look for objects and properties that I need to check. From you I got to know that I need to look into the "dataObjects" object.



Also, I am wondering how to update my list of the attachments when the user adds or removes the attachments. Which event (where) should I place the code for updating my list.



Please help.

Thanks.

Avatar

Level 5
Ali:

You can retrieve more info about your data objects.



app.alert("Data Object[" + i + "].path=" + d[i].path);

app.alert("d.MIMETyle: " + d[i].MIMEType);



Path is probably the one you want.

The "Acrobat JavaScript Scripting Reference" describes the methods & properties available. You can usually find it via Google.



The list of attachments should be automatically updated if the user is using the UI features to add/remove attachments.



Good Luck

Mark

Avatar

Level 1

Hi Mark,

Could you please tell how to read/display the contents of the attached file.

For eg: d[i].name gives me the name of the attached file.

Similarly do we have some d[i].<properties> to get the contents of the attached file?

Thanks and Regards,

Taha