Copy link to clipboard
Copied
I have found countless sites that explain how to create it in the older versions with coding like this (var f = this.getField("Today");
f.value = util.printd("mmm/d/yyyy", new Date());). I can't seem to find how to create it now. I need the date to automatically fill in with the current date upon opening. Please help!
I'm sorry, I misunderstood your question. When you mentioned "stamp", I thought you meant a dynamic stamp that you place on a document.
The procedure for adding a document-level JavaScript with Acrobat DC is:
1. Select: Tools > JavaScript
2. Select "Document JavaScripts" from the toolbar that appears at the top
3. Give the new document JavaScript a name, such as "init".
4. Click the Add button
5. In the window that appears, delete all of the code that it provides by default (an empty function) and ent
...Copy link to clipboard
Copied
The same script will work in DC. It needs to be a custom calculation script for a text field.
Copy link to clipboard
Copied
Also, if you want place the code in the calculate of the field named "Today", it should be changed to:
// Custom calculation script for "Today" text field
event.value = util.printd("mmm/d/yyyy", new Date());
This also assumes everything else is in place for the page/file for it to be a valid dynamic stamp.
Copy link to clipboard
Copied
I don't know what I'm doing incorrectly. I can't get it to work for me. I have added the coding to the custom calculations tab. I made sure the text box was read only and named Today . I can't find where to add the script that would populate that field upon opening. Can someone give me a step by step explanation? I would really appreciate it!
Copy link to clipboard
Copied
You don't want to add a script to populate the field when opened, so ignore that. I'd like to back up a bit and ask a few more questions:
Is the PDF you're working with a valid stamp file? If you're able to use it as a stamp currently, even though the auto-date field isn't working, the answer would be yes.
If it isn't a valid stamp file and you're creating it from scratch, review the following tutorial for more information: Creating a PDF Stamp File from Scratch - KHKonsulting LLC
You may be using a different version of Acrobat, but the basics are the same. The point is there are a number of things that need to be in place for it to be a valid stamp file, as detailed in the tutorial.
Copy link to clipboard
Copied
A field is not the same as a dynamic stamp. A dynamic stamp is dynamic or interactive until it is place on the PDF. Then it becomes a non-dynamic stamp and any items displayed on the stamp face is not editable.
A form field remains dynamic until it is "flattened" or made part of the PDF content.
I would create a read only form field and then create a document level script to populate that field each time the PDF is opened.
Assuming a field name "Today" the document level script could be:
this.getField("Today").value = util.printd(("d-mmm-yyyy", new Date());
Copy link to clipboard
Copied
I used some coding that allowed me to add the date to populate upon printing. which is a fix for now, but id really like to have it populate upon opening.
Copy link to clipboard
Copied
I'm sorry, I misunderstood your question. When you mentioned "stamp", I thought you meant a dynamic stamp that you place on a document.
The procedure for adding a document-level JavaScript with Acrobat DC is:
1. Select: Tools > JavaScript
2. Select "Document JavaScripts" from the toolbar that appears at the top
3. Give the new document JavaScript a name, such as "init".
4. Click the Add button
5. In the window that appears, delete all of the code that it provides by default (an empty function) and enter the code you posted originally.
Document-level JavaScripts are executed when the document is opened, so the code placed there will behave as you want.
Copy link to clipboard
Copied
Thank you! that worked
Find more inspiration, events, and resources on the new Adobe Community
Explore Now