Skip to main content
Electric_hope6C12
Inspiring
April 12, 2020
Question

Load image on stamp by script

  • April 12, 2020
  • 1 reply
  • 2056 views

Hello.

 I'm creating a stamp. The stamp directly shows a form to collect some user data text. In addition, I  want that stamp has a image (it's a signature scanned) of the user. I was triying to do in several ways:

1) Set a image field, that directly loads an image preestablished in the folder user, trying to establish it with this code ( unsuccessfully) that I got form issue https://adobe.ly/2XuHQM4

trustedImport = app.trustedFunction(function(doc)
{
app.beginPriv();
var f = doc.getField("Image8");
f.buttonImportIcon("C:\Users\cesar\AppData\Roaming\Adobe\Acrobat\2017\Stamps\beard.png");
app.endPriv();
});
trustedImport(this);

The I  get Error:

NotAllowedError: Security settings prevent access to this property or method.
App.trustedFunction:278:Field Text5:Calculate


2) Set a image field, but allowing the user to chose the image from a browser. For this I need a button on the form, that opens a browser and chooes the image and the set in to the image field. Tryigin to discover a code that makes that action, I saw some code on forums. It's probably bad code, but I think you can take the idea I want.

var dlg = new Window('dialog','onClick test');
dlg.But1 = dlg.add('button',undefined,'Click Me');
dlg.But1.onClick = event.target.buttonImportIcon();
dlg.show();

Error:

ReferenceError: Window is not defined
281:Field:Calculate

This topic has been closed for replies.

1 reply

Thom Parker
Community Expert
Community Expert
April 12, 2020

Read this:

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

 

As for the second set of code that uses "new Window". That's the HTML DOM for JavaScript. Acrobat is different. If it's not in the Acroabat JavaScript References, you likely can't do it in Acrobat.

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
April 12, 2020

Consider joining this site, or buying the book. It explains all of these issues:

https://www.pdfscripting.com/public/All_About_PDF_Stamps.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Electric_hope6C12
Inspiring
April 13, 2020

I have join the place and I design the forms with Acroform. 
I am trying to discover how works the folder privileges. In the document https://bit.ly/2yaKzQt 

speak about the Folder Privileges and to insert the code in sctips in that folder but....not sure how It works. It means all the first code I have to save in a script .js placed in that folder ?? Automatically the new stamp will read all the scripts .js of that folders and pre-load all the functions??