500 pts. Making text field show 2 weeks ahead of current date

Posted on 2005-04-06
Last Modified: 2008-02-01

I have a text field in an acrobat 6 file called "today" and I want it to show 2 weeks ahead of the current date in MM/DD/YYYY format. Below is a solution given to me by khkremer. Can anyone add to this answer or give me another solution?

select the Form tool: "Tools>Advanced Editing>Forms>Text Field Tool" and draw a rectangle on your PDF document. This will bring up the preference dialog for this form field. Select the "General" Tab and specify "Today" as the field name. Look around on the UI, select all the tabs, but you don't need to make any more changes here. Close the dialog. Select "Advanced>JavaScript>Document JavaScript". Give the script a name (e.g. "OnOpen") and click on the "Add" button. Replace the complete function stub with this line:

this.getField("Today").value = "today's date";

Save the file, close it and reopen it. YOu will now have the string "today's date" in your field. This information plus the first link that I provided should get you started with adding date information to your documents. You can have multiple fields with the same name. This will then add the date to all of these in one operation.
Here is the link khkremer  made reference to, though I cannot make heads or tails of it.

Your help on this is greatly apprieciated!

Question by:coma12
    LVL 1

    Author Comment

    Here is a link to the pdf that I want to add the 2 weeks from current date text field to. The date is manually added right now, every day - ugggh.

    Also if I will need to make the date in red.


    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    Were you able to add the text field to the document as I suggested in your earlier question?
    LVL 44

    Accepted Solution

    Instead of the simple assignment from my sample, use this JavaScript instead:

    var dateField = this.getField("Text1");  // <-- Replace this with the field name for your date field
    var today = new Date();

    var newDateValue = today.valueOf();   // converts today to a number that we can calculate with

    newDateValue += (14 * 1000 * 60 * 60 * 24);  // add 14 days
                                          // 1000 miliseconds times 60 seconds times 60 minutes
                                          // times 24 hours times 14
    var adjustedDate = new Date(newDateValue);  // create a new date based on the newDateValue variable
    dateField.value = util.printd("mm/dd/yyyy", adjustedDate);       // format and assign the new date

    LVL 1

    Author Comment


    Thank you so much!!!

    I was hoping you were scanning the acrobat section.

    Once again you came through like a champ and saved the day!


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Acrobat’s JavaScript is a great tool to extend the application, or to automate recurring tasks. There are several ways a JavaScript can be added to the application or a document (e.g. folder level scripts, validation scripts, event handling scripts,…
    Update 21-May-2015: I temporarily removed the source code to make major changes to the program. Regards, Joe In a previous Experts Exchange article, How To Rename-Move a Batch of PDF Files Based on Contents of the Files (http://www.experts-exchan…
    In this video, we show how to perform Bates Numbering/Stamping of PDF documents using Power PDF Advanced, the newest product from the Document Imaging division of Nuance Communications. There are two editions of Power PDF — Standard and Advanced. Th…
    Sometimes we receive PDF files that are in the wrong orientation. They may be sideways or even upside down. This most commonly happens with scanned or faxed documents. It is possible to rotate the view of these PDFs with the free Adobe Reader produc…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now