Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Opening an attachment

Avatar

Former Community Member

I have a list box with 3 buttons, attach, open and delete. The attach and delete buttons work fine when I attach or delete an attachment but when I click on the attachment button it does not open the attachment saying the is no attachment.

I am running Acrobat X Pro.

My code is:-

try}

var myDoc = event.target;

var sFile = Attachments.rawValue;

myDoc.exportDataObject ({ cName: sfile, nlaunch: 2 });

}

catch(e)

{

app.alert("There are no files to open");

}

2 Replies

Avatar

Former Community Member

JUst try it with the following code. Hope this helps...

var oObj = event.target;

var fileAttachments = oObj.dataObjects;//dataObjects returns all dataObjects(attachments)in the pdf

//attachmentsList is a listbox field in the form listing all the attachments included

if(attachmentsList.length > 0)

{

  oObj.importDataObject(fileAttachments.length);

  var oDataObj = oObj.getDataObject(fileAttachments.length);

  attachmentsList.addItem(oDataObj.path);

  //console.println("The attachments size is...."+fileAttachments.length);

  //NoOfAttachments is the text field showing total no. of attachments

  NoOfAttachments.rawValue = fileAttachments.length+1;

}

else

{

//we need to associate each file attachment  imported into the document with a key

//then get the file attachment's name and add it to the drop down list

oObj.importDataObject(counter.value);

var oDataObj = oObj.getDataObject(counter.value);

attachmentsList.addItem(oDataObj.path);

NoOfAttachments.rawValue = 1;

}

thanks.

Balaji