Copy link to clipboard
Copied
Script reading a text file works fine in Acrobat Pro, but not in Reader.
Is it a configuration issue ? Thanks.
You need to install your .js file in the JavaScripts folder of Reader for it to work. Currently you probably only have it under the Acrobat folder.
Copy link to clipboard
Copied
What is the code for the script?
Not all code that works with Acrobat will work with Reader.
Make sure you are not in the PDF/A or somilar mode.
Make sure JavaScript is ensbled.
Copy link to clipboard
Copied
Script in a Button :
try {
var oRet=myTrustedReadFile("/c/temp/mynotes.txt")
var txtval=this.getField("mytextfield")
txtval.value=oRet
} catch(e) {
console.println("User cancelled action");
}
Script In config.js :
myTrustedReadFile = app.trustedFunction( function ( oArgs )
{
app.beginPriv();
var rStream = util.readFileIntoStream(oArgs);
var cFile = util.stringFromStream(rStream);
app.endPriv();
return cFile;
});
Not in PDF/A and javascript is enabled.
Copy link to clipboard
Copied
1. What does it say in the console on Reader?
2. Did you check the Quick Bar in the API Reference for each method you use to see its Reader status?
3. Please randomize the privileged functions name more, you have created a vulnerability.
Copy link to clipboard
Copied
1. In console:
Error
ReferenceError: myTrustedReadFile is not defined
2. I can't find util.readFileIntoStream in reference (?)
util.stringFromStream(rStream) - No problem in QB
3. I not sure I understand : it's only to change the function name ?
Copy link to clipboard
Copied
You need to install your .js file in the JavaScripts folder of Reader for it to work. Currently you probably only have it under the Acrobat folder.
Copy link to clipboard
Copied
That's it. The config.js must be in other location.
Now it's working.
Thanks, very much appreciated.
Copy link to clipboard
Copied
What version of Acrobat and Reader are you using?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now