Highlighted

Pass argument to event.target.buttonImportIcon()

New Here ,
Sep 02, 2020

Copy link to clipboard

Copied

Hi.  I'm trying to import an image into an image field on a form by passing an argument.  The argument is the fully qualified path + file.  I saw the following short script in a post and I am trying to tweak it to make it work ...

 

var a =this.getField ("Hidden Text").valueAsString;

var b =this.getField ("Application Images(Screenshots)").valueAsString;

event.target.buttonImportIcon(a+b);

 

I have also tried to hard code the argument, and the field will not accept the image. 

[ event.target.buttonImportIcon("/C/myPath/Image1.jpg"); ]

I get nothing ... Any suggestions would be much appreciated.  Thanks!!

TOPICS
Acrobat SDK and JavaScript

Views

89

Likes

Translate

Translate

Report

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

Pass argument to event.target.buttonImportIcon()

New Here ,
Sep 02, 2020

Copy link to clipboard

Copied

Hi.  I'm trying to import an image into an image field on a form by passing an argument.  The argument is the fully qualified path + file.  I saw the following short script in a post and I am trying to tweak it to make it work ...

 

var a =this.getField ("Hidden Text").valueAsString;

var b =this.getField ("Application Images(Screenshots)").valueAsString;

event.target.buttonImportIcon(a+b);

 

I have also tried to hard code the argument, and the field will not accept the image. 

[ event.target.buttonImportIcon("/C/myPath/Image1.jpg"); ]

I get nothing ... Any suggestions would be much appreciated.  Thanks!!

TOPICS
Acrobat SDK and JavaScript

Views

90

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Sep 02, 2020 0
Adobe Community Professional ,
Sep 02, 2020

Copy link to clipboard

Copied

Using the "Path" parameter in this function require Privilege, i.e. it is restriced for security reasons. 

Here's the reference entry:

https://help.adobe.com/en_US/acrobat/acrobat_dc_sdk/2015/HTMLHelp/#t=Acro12_MasterBook%2FJS_API_Acro...

 

Here's an article that discusses "trust/privilege" in Acrobat Scripts.

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

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 02, 2020 0
Most Valuable Participant ,
Sep 02, 2020

Copy link to clipboard

Copied

Read the highlighted part carefully:

 

try67_0-1599076742567.png

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 02, 2020 0
Adobe Community Professional ,
Sep 02, 2020

Copy link to clipboard

Copied

If you want to pass a path parameter to the import function, then the user has to do something to create trust. For example, adding the PDF to the set of trusted documents in enhanced security, or installing a folder level script. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 02, 2020 0
Engaged ,
Sep 02, 2020

Copy link to clipboard

Copied

Hi, have you consider a workaround instead of buttonImportIcon to use buttonGetIcon() , with hidden button field?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 02, 2020 0
New Here ,
Sep 02, 2020

Copy link to clipboard

Copied

Thanks for the quick reply!  Turned on menu privileges.  Did not work.  Also tried turning off global security policy ... NG.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 02, 2020 0
Adobe Community Professional ,
Sep 02, 2020

Copy link to clipboard

Copied

Read the reply of Thom Parker.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 02, 2020 0