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

Creation of a custom dynamic stamp with Identifier

Community Beginner ,
Jul 07, 2025 Jul 07, 2025

Mystical_passion8499_1-1751880642954.png

Hello,

I would like to create a dynamic stamp composed of three different fields. The first field should include the Name and Identifier in the format "Name (Identifier)" from the "Identity" section of Adobe preferences. The second field should display the current date, and the third field should show the name of the file on which the stamp is applied. Here is an example. I have already tried, but only the date is dynamic; the rest does not work, and I am getting error messages in the JavaScript console saying that I do not have the necessary permissions. This stamp should be able to work across multiple sessions. The goal is to copy and paste it onto several users' PCs in the stamp directory on the C drive or the hidden AppData folder of Adobe.

Thank you.

TOPICS
JavaScript
2.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
3 ACCEPTED SOLUTIONS
Community Expert ,
Jul 11, 2025 Jul 11, 2025

bonjour,
C'est beaucoup plus simple que ça, tu as juste besoin de ce script :

event.value=identity.name+" ("+identity.loginName+")";
this.getField("Date").value=util.printd("mm/dd/yy", new Date());
this.getField("Certificat").value=event.source.source.documentFileName.replace(/\.pdf$/i,"");

Ce qui donne avec le fichier joint :

Capture_d’écran_2025-07-11_à_18_10_56.pngCapture d’écran 2025-07-11 à 18.25.38.png

@+

View solution in original post

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 ,
Jul 11, 2025 Jul 11, 2025

As mentioned previously in the thread, the conditional statements were included to avoid errors when the calculation runs before the stamp is applied and in case the file contained more than 1 stamp.

View solution in original post

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 ,
Jul 16, 2025 Jul 16, 2025

1.  There are two ways to do this.

a)  Open the stamp file and run the following script in the console:  this.templates

b)  Apply the stamp to a PDF, select the stamp and run the following script in the console:  this.selectedAnnots[0].AP

https://youtu.be/DePWr_1lnYg?t=184

2) Yes.  this.getField("File Name").value = app.repsonse("Enter file name:");

3)  Make the stamp field a multiline text field.

4)  By "lock", if you mean the locked check box in the appearance tab of the stamp properties is checked, you simply set the lock property of the stamp to true.  Anybody can access the properties and uncheck the box.  If you want the stamp to be locked so that there can be no user interaction with the stamp after it is placed, simply set the readOnly property to true.  This can only be undone with a script.  Having either of the settings executed automatically as the stamp is applied is proprietary information that I'm not willing to share here since most of the experts say it can't be done.

5.  You'll have to either change the template name or the document Title (which is the category in the stamp menu).  The template name mush begin with # or the stamp may only function once in a session.

View solution in original post

Learn JavaScript for Acrobat Pro. Take the eLearning Course: https://www.pdfautomationstation.com/public/Learn-To-Use-Adobe-Acrobat-Pro-DC-Like-A-Professional.cfm Weekly tips and tricks column: https://pdfautomationstation.substack.com/ This video shows how to add dynamic fields to a PDF stamp ...
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
Adobe Employee ,
Jul 07, 2025 Jul 07, 2025

 

Hi @Mystical_passion8499,

 

 

Thanks for reaching out and for sharing your use case with the community!

 

Creating a custom dynamic stamp that pulls the Name (Identifier) from the user’s Identity preferences, along with the current date and the file name, is a powerful but slightly nuanced task in Acrobat due to JavaScript security restrictions and session persistence. Here’s how you can approach this:

 

Your Goal:

Create a dynamic stamp with three fields:

  1. Name and Identifier from Edit > Preferences > Identity

  2. Current Date

  3. File Name of the PDF being stamped

 

 

Step-by-Step Solution:

1. Create the Base Stamp File

  • Open Acrobat or any PDF editor.

  • Add form fields named:

    • userInfoField

    • dateField

    • fileNameField

     

  • Save the file as a single-page PDF.

 

2. Add this JavaScript in the Stamp Field (custom calculation script):

You’ll need to add the following code inside the form fields (you can use a custom calculation script in each):

 

For userInfoField:

try {

    var identityName = https://adobe.ly/3GtLxe3;

    var identityLogin = identity.loginName;

    if (!identityLogin) identityLogin = "NoID";

    event.value = identityName + " (" + identityLogin + ")";

} catch (e) {

    event.value = "Unknown User";

}

 

 

For dateField :

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

 

 

For fileNameField:

try {

    event.value = this.documentFileName;

} catch (e) {

    event.value = "Unknown File";

}

 

 

 

Important Notes:

  • If you see messages like “not allowed due to security settings”, it’s due to Acrobat’s sandboxing of dynamic stamp scripts, especially when trying to access privileged objects like identity.

  • To make this work:

    • Use the app.getIdentityString() method only inside a dynamic stamp context.

    • Ensure your script is placed directly inside the dynamic stamp’s calculation script, not in a global or document-level script.

     

 

Working Stamp JavaScript (All in One Field - Optional Approach):

If you prefer one single text field for all values:

 

try {

    var name = https://adobe.ly/3GtLxe3 || "Unknown";

    var id = identity.loginName || "NoID";

    var date = util.printd("dd-mmm-yyyy", new Date());

    var fileName = this.documentFileName || "NoFile";

    event.value = name + " (" + id + ")\n" + date + "\n" + fileName;

} catch (e) {

    event.value = "Stamp Error: " + e.toString();

}

 

 

 

Deployment :

  • Once you save your dynamic stamp PDF, place it in the user’s stamp folder:

    • C:\Users\<username>\AppData\Roaming\Adobe\Acrobat\<version>\Stamps\

     

  • Acrobat will auto-load any valid stamp PDFs from this folder on the next launch.

 

Some Notes:

  • Ensure Acrobat is restarted after copying stamp files.

  • If the identity fields are blank, users may need to set their Identity under:

    • Edit > Preferences > Identity

     

  • This stamp can work across multiple sessions as long as users have Acrobat (not Reader in strict mode), and permissions allow access to Identity info.

 

 

Wait for more inputs form the experts.

 

 


~Tariq

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 ,
Jul 07, 2025 Jul 07, 2025

Please upload the stamp file.

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 ,
Jul 07, 2025 Jul 07, 2025

Thank you for your responsiveness. Here is the dynamic stamp with the authorization issues that I tried to create. I don't have Adobe Pro on my session, but I can do it on someone else's computer who has a Pro license. I would like to clarify that it should not be possible to change the identifier, as it is supposed to prove that the person logged into this session validated the document with the stamp.

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 ,
Jul 07, 2025 Jul 07, 2025

So first, there is no script in the "Nom" field. The script in this field should be set as shown by Tariq. 

The 3rd field, places the name of the stamp file in the field, not the name of the file being stamped. 

The document object for the file being stamped is in the 

even.source.source property

So the script should be 

 

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

 

BTW: Tariq did a fantastic write up. You should read it. 

 

 

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 ,
Jul 07, 2025 Jul 07, 2025

The identity object can only be accessed from a privileged context, or in a dynamic stamp environment.  As soon as you close the field property window of a field to which you have added a calculation script, the calculation will run.  Since this is not a privileged context and the calculation is running in a non-dynamic stamp environment, it will throw a security error.  It won't throw an error when the script runs as part of the stamping process.  To avoid this you should put the following condition on your script:

if(event.source.forReal)

{/* Your script */}

event.source.forReal is only true during the stamp process.  In case you have more than one stamp in the same file (category) you should also add another condition that identifies the AP property of the stamp.  While not necessary, I find it helpful for troubleshooting to have one calculation script for all fields instead of a separate calculation for each field.  Here's the script using the tips above in a separate field created for the calculation only (with your other scripts removed):

if(event.source.forReal && event.source.stampName=="#FyKxg3RHkTARzoly-AusJA")
{
this.getField("Nom (Identifiant)").value=identity.name+" ("+identity.loginName+")";
this.getField("Date").value=util.printd("mm/dd/yy", new Date());
this.getField("Certificat").value=event.source.source.documentFileName.replace(".pdf","");
}

It's confusing to use parentheses in a field name, although it works.  If you don't create a separate field for the script, change this.getField("FieldName").value to event.value for the field above containing the 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 Beginner ,
Jul 08, 2025 Jul 08, 2025

Thank you for all the information.

I would indeed like to have a separate code for each field because the layout of my stamp is in the form of a table.

To summarize, on a user session with Adobe Pro:

  1. I fill in the identity section in the preferences.

  2. I create a stamp, retrieve my PDF file with the table layout and logo, choose the "Dynamic" category, and name the stamp.

  3. I open my stamp located in C:\Users\[username]\AppData\Roaming\Adobe\Acrobat\DC\Stamps, which is named with several letters and numbers.

  4. I create my three text fields and format them, then paste the custom script:

    • In the first field, Name (Identity):

      if(event.source.forReal && event.source.stampName=="#NomtamponAppdata") { this.getField("Nom (Identifiant)").value=identity.name+" ("+identity.loginName+")"; }
    • In the second field:

      if(event.source.forReal && event.source.stampName=="#NomtamponAppdata") { this.getField("Date").value=util.printd("mm/dd/yy", new Date()); }
    • In the third field:

      if(event.source.forReal && event.source.stampName=="#NomtamponAppdata") { this.getField("Certificat").value=event.source.source.documentFileName.replace(".pdf",""); }
  5. I save, restart, and test on a document. If it works, I copy this file and place it in the AppData directory of another user.

I had a few questions:

  1. Do I need to enable the JavaScript debugger to see errors?

  2. What is the difference with this code from Tariq?

    var identityName = identity.name; var identityLogin = identity.loginName; if (!identityLogin) identityLogin = "NoID"; event.value = identityName + " (" + identityLogin + ")"; try { // code } catch (e) { event.value = "Unknown User"; }

    For dateField:

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

    For fileNameField:

    try { event.value = this.documentFileName; } catch (e) { event.value = "Unknown File"; }
  3. I assume that https://adobe.ly/3GtLxe3 is a display issue and that it should be identity.name, correct?

  4. How do I use the method app.getIdentityString()?

If necessary, I prefer to clarify everything beforehand, as I do not have access to an Adobe Pro session as I would like.

Thank you in advance.

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 ,
Jul 08, 2025 Jul 08, 2025

You can still put the entire code in one field, but that's your choice.  Regarding step 4:

If you are going to put the scripts in each field, all instances of this.getField("FieldName") should be changed to event.value.

1.  You need to open it (press Ctrl +j).

https://pdfautomationstation.substack.com/p/the-javascript-console

2.  That code tests the identity.loginName property to see if it exists and if not, changes it to "NoID".  I'm really sure how it could not exist.  It also test the identity.name property for an error.  If the name property is not filled in in the preferences, it will not throw an error, it will simply return nothing.  @Tariq Ahmad 's file name script is pulling the stamp document file name, not the the doc being stamped, but he probably misunderstood that part of your question.

3.  Correct.

4.  I have no idea where that came from.  There is no application method by that name that I can find.

 

This dynamic stamp video shows how to make one from scratch (without using the interface).  It is helpful in learning all of the parts of the stamp.

 

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 ,
Jul 11, 2025 Jul 11, 2025

 

Hello, I tried to follow the procedure to install the Adobe stamp on a user's session. I created a dynamic stamp from my PDF template, then I reopened my stamp from AppData and created the three necessary text fields (Name, Date, Certificate). I created a fourth field called "Script" to insert all the code at once:

 

if(event.source.forReal && event.source.stampName=="#RYR1Emk23H4sHB2rDWL_zB")
{
this.getField("Nom").value=identity.name+" ("+identity.loginName+")";
this.getField("Date").value=util.printd("mm/dd/yy", new Date()); this.getField("Certificat").value=event.source.source.documentFileName.replace(".pdf","");
}

After saving, I search for my file in AppData and overwrite it. I close Adobe, then reopen another PDF file to test, and my stamp appears but nothing is filled in. Attached is the stamp from AppData. 

 

I don't understand how to do it? Best regards

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 ,
Jul 11, 2025 Jul 11, 2025

You are referencing the wrong template name (AP) in your script.  Change #RYR1Emk23H4sHB2rDWL_zB to #FyKxg3RHkTARzoly-AusJA and delete page 3 of your stamp file.

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 ,
Jul 11, 2025 Jul 11, 2025

Mystical_passion8499_0-1752244013893.png

Mystical_passion8499_1-1752244074416.png

I deleted the first page, so there is only the cover page left. I then changed the file name in the script, but it still doesn't work.

 

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 ,
Jul 11, 2025 Jul 11, 2025

You're still getting the AP wrong in your script.  This is it for the file you uploaded this time:

#eDfOEniZ99McqbVPx6QPDB

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 ,
Jul 11, 2025 Jul 11, 2025

bonjour,
C'est beaucoup plus simple que ça, tu as juste besoin de ce script :

event.value=identity.name+" ("+identity.loginName+")";
this.getField("Date").value=util.printd("mm/dd/yy", new Date());
this.getField("Certificat").value=event.source.source.documentFileName.replace(/\.pdf$/i,"");

Ce qui donne avec le fichier joint :

Capture_d’écran_2025-07-11_à_18_10_56.pngCapture d’écran 2025-07-11 à 18.25.38.png

@+

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 ,
Jul 11, 2025 Jul 11, 2025

As mentioned previously in the thread, the conditional statements were included to avoid errors when the calculation runs before the stamp is applied and in case the file contained more than 1 stamp.

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 ,
Jul 16, 2025 Jul 16, 2025

Hello, I tested the stamp by modifying the script with #eDfOEniZ99McqbVPx6QPDB and it works! Thank you very much! The script from "bebarth" also works, but it is indeed less secure if I use multiple stamps, which will be my case. I had a few other questions:

  1. How do I find the name of the AP stamp #eDfOEniZ99McqbVPx6QPDB? I would like to create two other stamps, almost identical.
  2. Instead of the automatic file name, can I have a pop-up that allows me to manually fill in this field?
  3. How can I make the content wrap to the next line if the text is too long?
  4. Is it possible to lock the stamp once it has been applied?
  5. For my third stamp, can I copy and paste this stamp into AppData, rename it, and remove the part of the script related to the file name?

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 ,
Jul 16, 2025 Jul 16, 2025

1.  There are two ways to do this.

a)  Open the stamp file and run the following script in the console:  this.templates

b)  Apply the stamp to a PDF, select the stamp and run the following script in the console:  this.selectedAnnots[0].AP

https://youtu.be/DePWr_1lnYg?t=184

2) Yes.  this.getField("File Name").value = app.repsonse("Enter file name:");

3)  Make the stamp field a multiline text field.

4)  By "lock", if you mean the locked check box in the appearance tab of the stamp properties is checked, you simply set the lock property of the stamp to true.  Anybody can access the properties and uncheck the box.  If you want the stamp to be locked so that there can be no user interaction with the stamp after it is placed, simply set the readOnly property to true.  This can only be undone with a script.  Having either of the settings executed automatically as the stamp is applied is proprietary information that I'm not willing to share here since most of the experts say it can't be done.

5.  You'll have to either change the template name or the document Title (which is the category in the stamp menu).  The template name mush begin with # or the stamp may only function once in a session.

Learn JavaScript for Acrobat Pro. Take the eLearning Course: https://www.pdfautomationstation.com/public/Learn-To-Use-Adobe-Acrobat-Pro-DC-Like-A-Professional.cfm Weekly tips and tricks column: https://pdfautomationstation.substack.com/ This video shows how to add dynamic fields to a PDF stamp ...
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 ,
Jul 22, 2025 Jul 22, 2025
LATEST

Thank you so much!! I was able to create the second dynamic stamp with a pop-up and line break, also setting the font size to automatic. Note: it's "app.response" and you should use "," instead of "⨠". The read-only and locked properties don't affect the stamp itself, only within the script. However, if you right-click the stamp and choose Lock, then it can't be deleted.
Do you know if there's a way to make the stamp undeletable without having to perform this extra step?

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