Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Where did you place that code, exactly? You should review the security restrictions in place for the buttonImportIcon method.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Try:
trustedImport();
Copy link to clipboard
Copied
The same result.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks a lot. Modified code like this:
trustedImport = app.trustedFunction(function(doc)
{
app.beginPriv();
var f = doc.getField("imgField");
f.buttonImportIcon("/C/pdf/resources/image.pdf");
app.endPriv();
});trustedImport(this);No error, but nothing happens.
Copy link to clipboard
Copied
Many thanks to you. All works fine. I'm just had to execute
this.flattenPages()
in image.pdf
Thank you.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more