Skip to main content
alastairy53388845
Participant
May 23, 2020
Answered

Using buttonImportIcon from within button field

  • May 23, 2020
  • 3 replies
  • 1004 views

I have a piece of script that was run by a mouse up event within a button field that used to work on a previous version of Acrobat Professional on a Mac (I may have had to change a setting or something to get it to work but I can't for the life of me remember what). I have upgraded to Catlalina and due to non-64 bit software being allowed I am now using DC but I am now getting a security error. The script and error are below, if anyone could help resolve that would be appreciated. 

 

On Mouse Up run javascript 

a = this.getField("HiddenText").valueAsString; b = this.getField("RelevantIcon").valueAsString; console.println(a+b); event.target.buttonImportIcon(a+b);

 

Console message:

/Macintosh HD/Users/xxxxx/Desktop/001.pdf NotAllowedError: Security settings prevent access to this property or method. Field.buttonImportIcon:4:AcroForm:Button1:Annot1:MouseUp:Action1

 

This topic has been closed for replies.
Correct answer Thom Parker

Yes, there was a time when field.buttonImportIcon() worked with path input, even though the reference has shown it as restricted since Acrobat 7.  But it is restricted. 

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm?sd=40

 

 

3 replies

alastairy53388845
Participant
May 24, 2020

Thank you

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
May 23, 2020

Yes, there was a time when field.buttonImportIcon() worked with path input, even though the reference has shown it as restricted since Acrobat 7.  But it is restricted. 

https://www.pdfscripting.com/public/Trust-and-Privilege-in-Acrobat-Scripts.cfm?sd=40

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
May 23, 2020

It must have been a very old version of Acrobat if it worked.

You can no longer specify the path of the file to import, unless you run the code from a trusted context, such as a folder-level script installed on the user's local machine.