Skip to main content
cb112358
Participant
January 25, 2018
Answered

Acrobat Dynamic Stamp JavaScript not firing when stamp is first selected

  • January 25, 2018
  • 1 reply
  • 2955 views

I am trying to create a dynamic stamp in Adobe Acrobat XI Pro, that I can distribute to other users to use with minimal work on their end to use it. This stamp is an image that I've added a single text field to, and in this field I've inserted the following JavaScript code in Calculate > Custom calculation script:

console.println("Hello, World!");

event.value = "";

if (event) promptUser();

function promptUser()

{

var d = app.response();

event.value = util.printd("mmm dd yyyy", new Date(Date.parse(d))).toUpperCase();

}

When I am in editing mode with this form, and close the built-in JS editor window with this code, I see "Hello, World!" in the JavaScript Debugger window, and I get a prompt to input a date. However, whenever I save this stamp, then add it as a custom stamp, then try to use this, it remains whatever date it was saved as, without a prompt to input a date, and without outputting "Hello, World!" to the JavaScript Debugger window.

What am I missing to get this stamp to work, so that each time a user selects this stamp to insert it into a PDF, it will prompt them for the date they want to use on the stamp?

This topic has been closed for replies.
Correct answer Thom Parker

There are many parts to a dynamic stamp. They all have to be in place for it to work. The code you have here is insufficient by itself. Just as an example the stamp name has to be prepended with "#" in order for the script to be run when the stamp is selected, and there is much more.

Read the content on these pages and watch the linked videos

PDF Stamp Annotations

https://acrobatusers.com/tutorials/dynamic_stamp_secrets

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 25, 2018

There are many parts to a dynamic stamp. They all have to be in place for it to work. The code you have here is insufficient by itself. Just as an example the stamp name has to be prepended with "#" in order for the script to be run when the stamp is selected, and there is much more.

Read the content on these pages and watch the linked videos

PDF Stamp Annotations

https://acrobatusers.com/tutorials/dynamic_stamp_secrets

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
January 25, 2018

Please watch the video on installing a dynamic stamp in the first link. I'm quite sure your first main issue is that you are using either the Create Stamp or Import Stamp tool to import the stamp into Acrobat. This will completely destroy all dynamic features.

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