These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Check for Attachment in offline PDF Form

amiara
Registered: Feb 12 2008
Posts: 5

Hi Experts,

I am working on a scenario wherein i need to check if there is an attachment along with this form or not. Is there anyway we check this, while this form will always work Offline.

Any pointers to this will be helpful..

Thanks,
Amita

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You have an answer in your previous post [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=19460=]Check for Attachment in offline PDF Form[/url]. This can only be done with JavaScript.

George Kaiser

amiara
Registered: Feb 12 2008
Posts: 5
HI,

Can you plz elaborate on where exactly do i write the script, I didn't get what script line shall i write.

I am very new to ADOBE forms.

Thanks a lot for your help.


Thanks,
Amita
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You have to count the file attachment annotations and the MIME data objects.

this.syncAnnotScan(); // scan the PDF for annotationsaAnnots = this.getAnnots({nSortBy:ANSB_Type}); // get array of annotations sorted by type.// count the number of "FileAttachment" annotation typesvar sumAttachments = 0; // clear counter// loop through elements of annotation arrayfor (var i = 0; i < aAnnots.length; i++) {if(aAnnots[i].type == 'FileAttachment') sumAttachments++; // count FileAttachment} // end of loop // count the data objcts with a MIMETypevar aDataObj = this.dataObjects;var sumObjects = 0;// loop through teh data objectsfor (var i = 0; i < aDataObj.length; i++) {// count all object with a MIMETypeif(aDataObj[i].MIMEType != '') sumObjects++;} // sum total files foundvar sumFiles = sumAttachments + sumObjects; // check to see we have file attachmentsif(sumAttachments > 0) {// actions to take if there are attachmentsconsole.println("Number of Annotations: " + aAnnots.length);console.println("Number of FileAttachments: " + sumAttachments);} else {// actions to take if no file attachmentsconsole.println("Number of Annotations: " + aAnnots.length);console.println("Not FileAttachments were found.");} // end of attachment count processing // check to see we have file data objectif(sumObjects > 0) {// actions to take if there are attachmentsconsole.println("Number of Objects: " + aDateObj.length);console.println("Number of DataObject files: " + sumObjects);} else {// actions to take if no file attachmentsconsole.println("Number of Objects: " + aDateObj.length);console.println("No DataObject files found.");} // end of DataObject file  count processing // check if we have filesif(sumFiles > ) {// actions for found filesconsole.println("Total files found = " + sumFiles);} else {// action for no files foundconsole.println("No files found.");} // // end of total files

George Kaiser

eloralon
Registered: Dec 30 2008
Posts: 16
Hi gkaiseril,

I want to be able to do add the below functionality to my PDF form developed in LiveCycle Designer 8.2.

1) Create a button to add attachments on the form;
2) Show the names of the attached files in a listbox below the attachment field;
3) Be able to remove/delete attached files by clicking on a second button.

Thank you very much for help.