I am trying to figure out how to import a text file into a PDF and set its contents to a text field.
I am using the following which works but prompts the user to choose a file. Is there any way to avoid having the user choose the file?
function contentLoad(){
this.importDataObject("MyData");
this.getField("myTextField").clearItems;
var oFile = this.getDataObjectContents("MyData");
var cFile = util.stringFromStream(oFile, "utf-8");
this.getField("myTextField").value = cFile;
}
In Page Properties>I added the function for Page Open
Thanks!!
If the code must be in the document, and you can control the format of the file you want to import, then you are better off using either "doc.importAnFDF()" or "doc.importAnXFDF()". All of these have the advantage that data is mapped to specific form fields, and with proper enabling they will work from reader. And, using the new Acrobat 9 cross domain enabling you should be able to avoid all the popup warnings.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script