Skip to main content
Participating Frequently
Mar 9, 2023 9:43 PM UTC
Answered

Dynamic stamp with author of pdf and date and time

Created a dynamic stamp to pull the author name (identity name) and current date and time.  When the stamp is placed nothing happens...took script from a youtube video and customized it.  Nothing.  Then canceled script and went into each field and put script...nothing.  I am a beginner so I apologize for the childlike description.

 

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

this.getField("Reviewer").value = identity.name;
this.getField("Datetime").value = util.printd("m/d/yyyy h:mm tt", new Date());

}

Thom Parker
Thom ParkerCorrect answer
Community Expert
Mar 10, 2023 3:33 PM UTC

The "stamp manager" in Acrobat cannot be used with dynamic stamps, because it destroys all dynamic features. 

Dynamic stamp files have to be managed manually. 

 

Putting the code into the separate fields is the right way to go. 

Also, as Bebarth suggested, the "if" statement is unnecessary. This "if" is only used when there is user interaction.

You can find more info at these links:

https://acrobatusers.com/tutorials/dynamic_stamp_secrets/

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

 

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

20 replies

bebarth
Community Expert
Community Expert
Mar 10, 2023 10:52 AM UTC

...in fact if you only need to fill both fields, you don't need all this script!

For the "Reviewer" field:

 

event.value=identity.name;

 

and for the "Datetime" field:

 

event.value=util.printd("m/d/yyyy h:mm tt", new Date());

 

Try my attached file to check.

@+

Translate
Participating Frequently
Mar 14, 2023 9:52 PM UTC

Thank you very much!

Translate
try67
Community Expert
Community Expert
Mar 10, 2023 9:36 AM UTC

How did you find the value for the stampName property?

Translate
Participating Frequently
Mar 10, 2023 1:22 PM UTC

control j

this.templates 

and it gave me the #customerservice

Translate
try67
Community Expert
Community Expert
Mar 12, 2023 9:16 AM UTC

 Did you create the stamp file yourself, or did you create it via Acrobat's interface, and then edited it? Because that's not how Templates are named when you do it using the latter (which is the correct way of doing it).

Translate
bebarth
Community Expert
Community Expert
Mar 10, 2023 12:16 AM UTC

Hi,

What is the name of the template?

@+

Translate
Participating Frequently
Mar 10, 2023 1:17 PM UTC

contact review stamp.pdf

Translate
bebarth
Community Expert
Community Expert
Mar 10, 2023 2:52 PM UTC

I didn't mean the name of the file but the name of the template!

Following the answer you gave to Thom (3) it seems you don't get the right process...

Have a look on my previous answer and place the file into the "Stamps" folder of your Acrobat application.

@+

Translate
Thom Parker
Community Expert
Community Expert
Mar 9, 2023 10:25 PM UTC

There aren't any errors in your script, at least as long as the field names and the stamp name are correct.

 

When you edited the stamp to add the scripts, 

1) did you add them to the custom calculation for each field?

2) Did you edit the dynamic stamp in the stamps folder? Or did you import the edited stamp into Acrobat using the stamp tools?

 

Take a look at the info here for more info on Acrobat Stamps.

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

 

Translate
Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
Mar 10, 2023 1:16 PM UTC

Thank you for your response!!!  

 

1) I created a script field in the stamp itself.  It didn't work

2) I then deleted the field and entered the code into each field's properties under calculate custom and the name still doesn't pull up and the datetime field shows the datetime when I inserted the original code

3)I saved it as a template and used the stamp manager to add the custom stamp to the stamps list.  It appears but it isn't dynamic.

Translate
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
Mar 10, 2023 3:33 PM UTC

The "stamp manager" in Acrobat cannot be used with dynamic stamps, because it destroys all dynamic features. 

Dynamic stamp files have to be managed manually. 

 

Putting the code into the separate fields is the right way to go. 

Also, as Bebarth suggested, the "if" statement is unnecessary. This "if" is only used when there is user interaction.

You can find more info at these links:

https://acrobatusers.com/tutorials/dynamic_stamp_secrets/

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

 

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