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

Opening an attachment

Avatar

Not applicable

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

Level 2

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

Avatar

Not applicable

Is your form password protected?