Skip to main content
Participating Frequently
Mar 20, 2020 3:25 PM UTC
Answered

Adding image to a stamp dynamically

Hello everyone. I'm trying to make a dynamic stamp with image. This image must change depending on which user stamping pdf(going to use identity.loginName, got this property right).

I'm trying to add image via

 

 

var f = this.getField("imgField");
f.buttonImportIcon("/C/pdf/resources/image.pdf");

 

 

but nothing works. Console returns 0 but no image appears on field. Using image field (property set to "icon only").  Is there a way to make this work on Acrobat Reader DC? Help pls.

This topic is closed to new replies. Start a new post to keep the conversation going.
George_JohnsonCorrect answer
Inspiring
Mar 20, 2020 4:08 PM UTC

Look at the documentation for app.beginPriv and app.endPriv and the code samples it links to.

 

You should also pass the document object to the trusted function and use it in place of "this" in the code in the function.

8 replies

try67
Community Expert
Community Expert
Mar 20, 2020 3:47 PM UTC

Quite a lot of information missing here. Did you add the image field to the stamp? If so, where did you place the code?

Are you aware of the limitations of buttonImportIcon? Did you check the JS Console after applying the stamp?

And where does the username come into play here?

Translate
Participating Frequently
Mar 20, 2020 3:56 PM UTC

I made a most stupid mistake ever. Pls sorry i made my request incorectly. I'm just making a form which have to became a stamp 😞

Yes, image field in pdf. But i put my code into JS console. Now i've created a js file with following content:

trustedImport = app.trustedFunction(function()
{
var f = this.getField("imgField");
f.buttonImportIcon("/C/pdf/resources/image.pdf");
});

 Put this file into C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts

Then put this code in "Custom calculation script"

app.trustedFunction(trustedImport);

 and getting NotAllowerError.

Translate
Participating Frequently
Mar 20, 2020 5:15 PM UTC

Look at the documentation for app.beginPriv and app.endPriv and the code samples it links to.

 

You should also pass the document object to the trusted function and use it in place of "this" in the code in the function.


Many thanks to you. All works fine. I'm just had to execute

 

this.flattenPages()

 

in image.pdf

Thank you.

Translate
Inspiring
Mar 20, 2020 3:42 PM UTC

Where did you place that code, exactly? You should review the security restrictions in place for the buttonImportIcon method.

Translate