Skip to main content
Participating Frequently
March 18, 2021
Answered

File name to Dynamic Stamp

  • March 18, 2021
  • 1 reply
  • 3378 views

Would anyone know how to stamp the file name using JavaScript to my dynamic stamp in Acrobat.

Correct answer Thom Parker

From inside a stamp script the "this.documentFileName" will return the name of the stamp file, not the name of the file being stamped.

Use this code in a calculation script on the stamp to put the name of the file being stamped into the field.

 

event.value = event.source.source.documentFileName;

 

This is code is undocumented. You can read all about it here:

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

 

Find out everything you ever wanted to know about stamps here:

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

 

1 reply

Abambo
Community Expert
Community Expert
March 18, 2021

If I'm correct, you know how to create dynamic stamps? If not read here: https://helpx.adobe.com/acrobat/kb/create-custom-dynamicstamp.html

 

The JavaScript for getting a document's name is:

this.documentFileName

 

ABAMBO | Hard- and Software Engineer | Photographer
Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 18, 2021

From inside a stamp script the "this.documentFileName" will return the name of the stamp file, not the name of the file being stamped.

Use this code in a calculation script on the stamp to put the name of the file being stamped into the field.

 

event.value = event.source.source.documentFileName;

 

This is code is undocumented. You can read all about it here:

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

 

Find out everything you ever wanted to know about stamps here:

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

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
August 7, 2025

Saved to dynamic stamps but it did not fill in filename, remains blank. Only edited the script to remove the filetype. what's missing?

event.value = event.source.source.documentFileName.replace(/\.pdf$/i, "");