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

Dynamic Stamp

Community Beginner ,
Nov 20, 2019 Nov 20, 2019

Having an issue when creating a dynamic stamp. I am entering in a custom javascript and select that when creating my form on the dynamic stamp. When I hit okay, it automatically sets it back to "Field not calculated" instead of keeping my javascript. I even made an error at first and it called that out, I corrected it and it seemingly won't let me have that script be entered. here is what I am entering

 

var cAsk = "Enter POI Number" ;

var cTitle = "POI Number:  ";

if(event.source.forReal && (event.source.stampName == "#mH2CRwgU97QYytFkFHMANC"))

{

  var cMsg = app.response(cAsk, cTitle);

  event.value = cMsg;

  event.source.source.info.exhibit = cMsg;

}

TOPICS
Acrobat SDK and JavaScript
3.4K
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

correct answers 1 Correct answer

Community Expert , Nov 21, 2019 Nov 21, 2019

That error is from editing the stamp file, not from running it. It's not a problem, but if you want it to go away, then follow Try67's suggestion in his post at the bottom of the thread.

 

The stamp name is not the file name. The stamp name is part of the page template for the page that is the stamp.

Open up the "Organize Pages" tab and select the "More > Page Templates" menu item. You'll see the template name here.  

 

You can also get the template name be placing the stamp on a PDF page, selec

...
Translate
Community Expert ,
Nov 20, 2019 Nov 20, 2019

Try this:

Create a new field with this script.

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 ,
Nov 20, 2019 Nov 20, 2019

The problem is with Acrobat, not the script. I've seen this when using an external editor for scripts. I think Bernd's idea is a good one. Try creating a new field and starting over.  

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

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 Beginner ,
Nov 20, 2019 Nov 20, 2019

Thanks guys, I did create a new field and finally got the script in there. Closed the form editing and saved, however, now I am not getting the script to run when I post the stamp. Prompts aren't showing up to enter in the values

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 ,
Nov 20, 2019 Nov 20, 2019

Did you copy the stamp file the correct location?

Did you restart Acrobat after copying the stamp file?

 

 

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

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 Beginner ,
Nov 21, 2019 Nov 21, 2019

I accessed the static stamp in the stamps folder within Acrobat and then added the scripting and saved it back in that folder within Acrobat. I did restart acrobat and even this morning just turning on my computer it is still not showing

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 ,
Nov 21, 2019 Nov 21, 2019

Is the stampName correct?

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 Beginner ,
Nov 21, 2019 Nov 21, 2019

Right I double checked that, and I am using the stamp name in the user stamps folder. I tried to recreate it so now I have a different stampName, seen below and this is where I am getting it fromadobe.PNG

 

var cAsk = "Enter POI Number" ;
var cTitle = "POI Number: ";
if(event.source.forReal && (event.source.stampName == "#biB4tIWRwdqM4zhdqaW_MC"))
{
var cMsg = app.response(cAsk, cTitle);
event.value = cMsg;
event.source.source.info.exhibit = cMsg;
}

 

Also, I noticed that the debugger pops up showing this message:

TypeError: event.source is null
3:Field:Calculate

 

I am not too sure how to remedy that or if that is the cause of it not showing up

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 ,
Nov 21, 2019 Nov 21, 2019

That error is from editing the stamp file, not from running it. It's not a problem, but if you want it to go away, then follow Try67's suggestion in his post at the bottom of the thread.

 

The stamp name is not the file name. The stamp name is part of the page template for the page that is the stamp.

Open up the "Organize Pages" tab and select the "More > Page Templates" menu item. You'll see the template name here.  

 

You can also get the template name be placing the stamp on a PDF page, selected it, and then running this code in the Console Window

 

selectedAnnots[0].AP

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

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 Beginner ,
Nov 21, 2019 Nov 21, 2019

Oh man, yep that was it! Appreciate all the help guys

 

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
Community Expert ,
Nov 21, 2019 Nov 21, 2019
LATEST

You can find everything you ever wanted to know about Acrobat Dynamic stamps here:

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

 

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

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 ,
Nov 21, 2019 Nov 21, 2019

Change this line:

if(event.source.forReal && (event.source.stampName == "#mH2CRwgU97QYytFkFHMANC"))

To:

if (event.source && event.source.forReal && event.source.stampName == "#mH2CRwgU97QYytFkFHMANC")

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