Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript working in Acrobat but not Reader

I have created a form in Acrobat that includes a submit button. When the user clicks it I want certain fields to be exported as tab delimited text. In Acrobat, when the button is clicked the window opens, allowing me to select the folder to export into, and the data is exported. In reader nothing happens. The debugger gives me this error:

RangeError: Invalid argument value.
Doc.exportAsText:2:Field Submit:Mouse Up

I've looked and can't seem to find information on this error. My original script is this:

var aSubmitFields = new Array ( "Name", "Address")
this.exportAsText ({aFields: aSubmitFields})

As you can see it's very basic. I don't understand why it will not work.

EDIT: after removing the "a" from ({aFields I get the error:

NotAllowedError: Security settings prevent access to this property or method.
Doc.exportAsText:2:Field Submit:Mouse Up
like image 457
user1747741 Avatar asked Oct 15 '12 16:10

user1747741


People also ask

How do I enable JavaScript in Acrobat Reader DC?

To enable JavaScript in Adobe Acrobat Reader Open Adobe Acrobat Reader. Go to Edit > Preferences. In Categories, click JavaScript. In the JavaScript section, check Enable Acrobat JavaScript.

Why is my Acrobat Reader not working?

Update Acrobat Reader or Acrobat Installing the latest updates might solve the issue. Open Acrobat Reader or Acrobat. Select Help > Check for Updates. If the Updater dialog box appears, click Yes.

Can PDF execute JavaScript?

A JavaScript action allows execution of JavaScript code embedded in the PDF document. Essential PDF supports adding JavaScript action to the PDF document in the following: Document level JavaScript action.

How do I use JavaScript in Adobe PDF?

To open the Document Actions dialog, choose Tools > JavaScript > Document Actions. Select an action and then click Edit to add the script to the action.


2 Answers

To achieve this in Acrobat Reader first user will open tools>preferences, there user will see the security settings. Here first need to allow active contents to run

After doing this your code should work, the active contents like JavaScript are exploited by malicious users so this feature is disabled by default.

New versions with HotFix installed will not allow JavaScript, every time security hot fix applied it will disable the JavaScript/Active Content option..

I hope this will give you some insights towards solution..

like image 196
MarmiK Avatar answered Oct 05 '22 05:10

MarmiK


To be able to call exportAsText() in Adobe Reader you need to have "Advanced Forms Features rights" on document. You can see it in documentation pages 32 and 251. If you do not have this right on document you are calling JavaScript code on you will get "Security settings prevent access to this property or method." error.

This rights can be set when the document is created in Adobe Acrobat.

And the active content must be allowed in reader as the MarmiK already tell you.

like image 35
boucekv Avatar answered Oct 05 '22 06:10

boucekv