Expand my Community achievements bar.

Show File Open Dialog and get File

Avatar

Former Community Member
Am creating a document where I want to prompt the user with the File Open dialog box and when a file is selected, I want to get that file and attach to the document. I know the scripting allows files to be attached but how do I display the dialog and then attach using the script.



Will greatly appreciate the help.



Am using Adobe LiveCycle Designer 7



Thanks

Nilesh!
3 Replies

Avatar

Former Community Member
Yes I know I can do it via the document menu. But I know if I can do it via the script as I am developing an online assignment in PDF for our students. So it would be easier if I put buttons on the form and the students (who are not very good with computers) can just click the button, select a file and attach it to the document.

Avatar

Former Community Member
Hi Nilesh,



You can use the getDataObject method of the Adobe document object. Below is a sample script that you can attach to the click event of a button to see how it works. For more information on importDataObject and getDataObject go to

http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/javascript/AcroJS.pdf



SAMPLE

======



//Get a handle to the Adobe document object

var doc = event.target;



//Display a file dialog box and assign the name Attachment to the

//DataObject that contains the selected file.

doc.importDataObject("Attachment");



//Get the DataObject and store it in MyData

var MyData = doc.getDataObject("Attachment");



//Clear and display the console window

console.show();

console.clear();



//Output the properties of the DataObject

for (var i in MyData) console.println("MyData." + i + "=" + MyData[i]);



Trevor