Skip to main content
Participating Frequently
March 9, 2023
Answered

Dynamic stamp with author of pdf and date and time

  • March 9, 2023
  • 4 replies
  • 7485 views

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());

}

Correct answer Thom Parker

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

 

4 replies

bebarth
Community Expert
Community Expert
March 10, 2023

...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.

@+

Participating Frequently
March 14, 2023

Thank you very much!

try67
Community Expert
Community Expert
March 10, 2023

How did you find the value for the stampName property?

Participating Frequently
March 10, 2023

control j

this.templates 

and it gave me the #customerservice

try67
Community Expert
Community Expert
March 12, 2023

 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).

bebarth
Community Expert
Community Expert
March 10, 2023

Hi,

What is the name of the template?

@+

Participating Frequently
March 10, 2023

contact review stamp.pdf

bebarth
Community Expert
Community Expert
March 10, 2023

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.

@+

Thom Parker
Community Expert
Community Expert
March 9, 2023

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

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participating Frequently
March 10, 2023

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.

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 10, 2023

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