Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Jan 02, 2017 Jan 02, 2017

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

Is it a configuration issue ? Thanks.

TOPICS
Acrobat SDK and JavaScript , Windows
880
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 02, 2017 Jan 02, 2017

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.

Translate
LEGEND ,
Jan 02, 2017 Jan 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 02, 2017 Jan 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 02, 2017 Jan 02, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 02, 2017 Jan 02, 2017

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  ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 02, 2017 Jan 02, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 03, 2017 Jan 03, 2017
LATEST

That's it. The config.js must be in other location.

Now it's working.

Thanks, very much appreciated.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 02, 2017 Jan 02, 2017

What version of Acrobat and Reader are you using?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines