• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Load image on stamp by script

Community Beginner ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

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

TOPICS
Acrobat SDK and JavaScript

Views

530

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
community guidelines
Community Expert ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Community Expert ,
Apr 12, 2020 Apr 12, 2020

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

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
community guidelines
Community Beginner ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

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??

Votes

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
community guidelines
Community Expert ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

LATEST

You need to read about using the trusted function:

https://www.pdfscripting.com/public/Checkboxes-and-Radio-Buttons.cfm

 

And about folder level scripts, which are also used for automating Acrobat:

https://www.pdfscripting.com/public/Automating-Acrobat.cfm

 

Also read the Advanced Dynamic Stamp scripting article.

 

Folder level scripts are loaded and run when Acrobat is started. Any functions, variables, objects, etc. defined in a folder level script are available to any other script in Acrobat or a PDF.  So, if a stamp script needs to perform a privileged operation, you can defined a function for that operation in a folder level script, and then the stamp script can call that function. 

 

 

 

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

Votes

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
community guidelines