Skip to main content
Participating Frequently
November 1, 2005
Question

Add current date to PDF documents

  • November 1, 2005
  • 127 replies
  • 43045 views
This doesn't seem like it should be hard, but I have been unable to find information on how to do it.

I have about 100 PDF files. Somewhere on them, I need to display "Date Printed: dd mmm yyyy", and have the current date displayed.

I don't care whether this is placed at the top of the page, the bottom, or opaque in the background.

I would like to be able to accomplish it using the batch command, but will perform manually if necessary.

I have Acrobat 7 Professional.

Can someone please help me out?
    This topic has been closed for replies.

    127 replies

    Participant
    September 17, 2007
    Hi Thanks for reply
    I am using the script in a batch process and need to create the field on the fly Currently the script creates the field at the bottom of the page. I would like to have the message at the top of the page.
    Any help would be apreciated
    Inspiring
    September 17, 2007
    This script could be simplified or made clearer by using the "getDate()", "getMonth()" and "getFullYear()" methods.

    The original code:
    // Add Field to Document Script
    var strJS = 'var ofield = this.getField("DocMessage");';
    strJS += 'var theDate = (new Date((new Date()).valueOf() + 1000 * 60 * 60 * 24 * 14));';
    strJS += 'ofield.value = "PRINTED COPIES OF THIS DOCUMENT WILL EXPIRE AT MIDNIGHT ON";';
    strJS += 'ofield.value += " " + util.printd("dd mmm yyyy",theDate) + ". Do not use after this date.";';
    this.addScript("AddMessage",strJS);

    The revised code:
    // Add Field to Document Script
    var strJS = 'var ofield = this.getField("DocMessage");';
    var strJS += 'var oToday = new Date(); // get today's date time object;';
    // add 14 days to todays date - years and months can be modified by adding the number to the appropriate item
    strJS += 'var theDate = (new Date(oToday.getFullYear(), oToday.getMonth(), )oToday.getDate() + 14));';
    strJS += 'ofield.value = "PRINTED COPIES OF THIS DOCUMENT WILL EXPIRE AT MIDNIGHT ON";';
    strJS += 'ofield.value += " " + util.printd("dd mmm yyyy",theDate) + ". Do not use after this date.";';
    this.addScript("AddMessage",strJS);
    Bernd Alheit
    Community Expert
    Community Expert
    September 17, 2007
    You must add the text field at the top of the page.
    Participant
    September 16, 2007
    Hi This script is what I have been looking for.

    I would be extemely grateful if you could you tell me what the changes in the javascript would be to put the message at the top instead the bottom of the page.
    steve_foxall
    Participating Frequently
    June 15, 2007
    Maybe one of the script experts will help you, but if any user is clued up enough to do that to your document surely they are also smart enough to edit one to produce a print that says whatever they want. If the validity is that critical it might make more sense to 'serve' a re-dated version daily?
    Participant
    June 15, 2007
    I have everything working here except I have one last issue.

    PROBLEM:
    The util.printd() command requests the current date and time from the LOCAL machine viewing (executing) the PDF document.

    I need my PDF documents to pull the current date and time from a REMOTE machine (i.e. my company's server).

    COMMENTS:
    The util.printd(), as far as using it for "valid only on" watermarks, is not reliable. Since it executes using the local machine's date and time, I could, for example, just go into my PC's date&time tool, change it to a month ago, and wha-la!, my PDF document is now incorrectly valid, dating to the previous month. This issue could easily be used by competing organizations to cause confusion and accuse one another of false interpretation of the latest revisions to working documents.

    In summary, here is what I need to do:
    I need to pull the current date and time from a DEFINED (i.e. a time server) machine. Not the local machine.

    Does anyone else have this requirement and understand my need, and possibly have a fix for it?

    Thanks
    Wayne
    steve_foxall
    Participating Frequently
    June 5, 2007
    GC..
    To make something happen you are going to need code, which will either get there by conventional tools (like inserting fields) or by javascript, or both. The batch processes will apply it to a bunch of documents, and you could talk to the excellent Windjack solutions (mentioned above) who could no doubt make it all happen with a single button click (for a few $$$ of course!)
    Participating Frequently
    June 4, 2007
    Hi Steve:

    I tried #14. It works great. Thanks. Can I get something similar to work without cutting and pasting text fields into every document. Thanks for your help.
    GC
    Participating Frequently
    June 4, 2007
    GC -

    I guess I don't understand what exactly you are trying to do. I wanted the ability to process many documents at one time. If you are only creating 1 document at a time, you may want to look at a different solution.

    Also, I am not familiar with Acrobat 8.0, so I can't tell you any different ways to include a dynamic date using that version.

    Maybe check out message #14 like steve foxall suggested...
    Participating Frequently
    June 4, 2007
    Hi Dave:

    Thanks, I already tried your suggestion and it works great.

    However the document manager wants to have the "Print Date" on selected PDF documents without having to create any text boxes or copying code. Will the batch processor be an effective solution to this problem. I was unclear about how to setup a batch task in Acrobat 8 Pro, which on Print first creates a data-field, and then populates it with the current date.

    Thanks,
    GC