Skip to main content
Participant
September 24, 2023
Question

Lock pdf form from editing, fields are editable but javascript code assigned to button will not work

  • September 24, 2023
  • 3 replies
  • 549 views

I have created a pdf form document, with the normal textfields etc and everything is all good on that side there is also a couple of buttons which have actions to run a javascript, these run fine in the unlocked version however when I lock for editing allowing form fields to be completed etc everything works even the print and reset buttons however the two buttons I have that execute javascript are not working as expected in fact they do nothing at all. Any suggestions would be greatly appreciated.. I have the javascript enabled from within the menu as mentioned it runs fine when not locked with the password.

This topic has been closed for replies.

3 replies

try67
Community Expert
Community Expert
September 25, 2023

If you encrypt the file (which is what I understand you mean) and only allow filling-in form fields, that doesn't allow adding new fields (using a script or manually), as it's a form of editing.

Bernd Alheit
Community Expert
Community Expert
September 25, 2023

What scripts does you use at the two buttons?

Participant
September 24, 2023

on the javascript debugger i get the following:

 

NotAllowedError: Security settings prevent access to this property or method.
Doc.addField:163:Field btnRUAdd:Mouse Up

Thom Parker
Community Expert
Community Expert
September 25, 2023

Is it really necessary for the script to use the addField() function?  Could you place these fields on the form and hide them until needed?

  

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often