I am trying to select a text file, AddMe.js, to an open page action. I have been able to select a file, but not much more than that. And my research has not yielded any good results.
A) How does one indicate which file has been selected (2nd block of code)?
B) How does one convert the text file into a string to be used in setPageAction?
// 1. Prompt the user for a data file to embed.
this.importDataObject("fileJS");
// 2. Show file name in static_text box
dialog.load({"JaSc": this.getDataObject("fileJS").name});
// 3. Add JavaScript to first page, open
this.setPageAction(0, "Open", "//script from file" );
// 4. Remove file.
this.removeDataObject("fileJS");
C) if there is a better way, please let me know... (Adding a page with the JavaScript is right out.)
thank you for your help
System info:
Windows XP
Acrobat 9 Pro Extended (development environment, Me)
Acrobat 9 Pro (production environment, co-workers)
ps. I can't use LiveCycle Designer because I have Visual Studio installed.
pss. I am new to JavaScript/Acrobat programming etc...
// Prompt the user for a data file to embed.
curDoc.importDataObject("fileJS");
// get the file stream object of the embedded file
var jsFile = curDoc.getDataObjectContents("fileJS");
// convert to a string
var jsContents = util.stringFromStream(jsFile, "utf-8");
// Add JavaScript to first page, open
curDoc.setPageAction(0, "Open", jsContents);
I used this post for my code..
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=1308