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

How do I add a date stamp that autofills upon opening, in the new Acrobat Pro?

New Here ,
Mar 29, 2016 Mar 29, 2016

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!

TOPICS
Acrobat SDK and JavaScript
4.1K
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

correct answers 1 Correct answer

LEGEND , Mar 29, 2016 Mar 29, 2016

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

...
Translate
LEGEND ,
Mar 29, 2016 Mar 29, 2016

The same script will work in DC. It needs to be a custom calculation script for a text field.

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
LEGEND ,
Mar 29, 2016 Mar 29, 2016

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.

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
New Here ,
Mar 29, 2016 Mar 29, 2016

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!

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
LEGEND ,
Mar 29, 2016 Mar 29, 2016

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.

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
LEGEND ,
Mar 29, 2016 Mar 29, 2016

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

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
New Here ,
Mar 29, 2016 Mar 29, 2016

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.

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
LEGEND ,
Mar 29, 2016 Mar 29, 2016

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.

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
New Here ,
Mar 29, 2016 Mar 29, 2016
LATEST

Thank you! that worked

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