Skip to main content
cruzj89645772
Participating Frequently
January 2, 2017
Answered

Script running in Acrobat Pro doesn't run in Reader ?

  • January 2, 2017
  • 1 reply
  • 977 views

Script reading a text file works fine in Acrobat Pro, but not in Reader.

Is it a configuration issue ? Thanks.

This topic has been closed for replies.
Correct answer try67

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  ?


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.

1 reply

Inspiring
January 2, 2017

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.

cruzj89645772
Participating Frequently
January 2, 2017

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.

Legend
January 2, 2017

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.