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

Adding image to a stamp dynamically

New Here ,
Mar 20, 2020 Mar 20, 2020

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.

TOPICS
Edit and convert PDFs , PDF forms
3.0K
Translate
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
1 ACCEPTED SOLUTION
LEGEND ,
Mar 20, 2020 Mar 20, 2020

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.

View solution in original post

Translate
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
LEGEND ,
Mar 20, 2020 Mar 20, 2020

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

Translate
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 ,
Mar 20, 2020 Mar 20, 2020

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
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
New Here ,
Mar 20, 2020 Mar 20, 2020

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
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 ,
Mar 20, 2020 Mar 20, 2020

Try:

trustedImport();

Translate
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
New Here ,
Mar 20, 2020 Mar 20, 2020

The same result.

Translate
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
LEGEND ,
Mar 20, 2020 Mar 20, 2020

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.

Translate
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
New Here ,
Mar 20, 2020 Mar 20, 2020

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.

Translate
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
New Here ,
Mar 20, 2020 Mar 20, 2020
LATEST

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

 

this.flattenPages()

 

in image.pdf

Thank you.

Translate
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