Skip to main content
Participating Frequently
November 1, 2005
Question

Add current date to PDF documents

  • November 1, 2005
  • 127 replies
  • 43040 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

    Participating Frequently
    November 10, 2005
    That is awesome Reinhard - thank you so much.

    Can you explain the [30,12, 100,28] ?

    I would like the text box to be a single line high, about 90% the width of the document and have the text centered in it.

    How would I modify [30,12, 100,28] to get that?
    ReinhardF
    Participating Frequently
    November 10, 2005
    Here the JS, which will do it:

    for (var p = 0; p < this.numPages; p++)

    {

    var fd = this.addField("Date", "text", p, [30,12, 100,28]);

    fd.textSize=8;
    fd.value = "Date: " + util.printd("dd/mmm/yyyy", new Date());

    }


    HTH, Reinhard
    Participating Frequently
    November 10, 2005
    Dimitri -

    As I am really new to acrobat and javascript, would you be able to give example code for creating the text field? I have read the documentation on the doc.addField statement, but quite frankly it is over my head.

    Dave
    steve_foxall
    Participating Frequently
    November 10, 2005
    For v7 Pro (6 may be the same...?) To create a text box visible only when printing, select the Text Field tool, draw your rectangle and then on the General tab, change the Form Field to 'Hidden but Printable'. In the Options tab, change the Default Value to 'Printed On' (or any other message). Close the dialog box, and this text should now print with the document.

    With the Text Field tool selected again, right-click on the box and select 'Create Multiple Copies'. Adjust the options to create one copy immediately to the right of your first box. Right click on this new box and open its Properties. In the General tab, change its name to 'Today' (with no quotes). In the Options tab, delete the 'Printed On' text. In the Format tab, select dd mm, yyyy (but experiment).
    From the main Acrobat menus, select Advanced, Javascript, Document Javascripts and create a script called 'Today'. Delete the text that is entered by deault, and replace it with:-

    var f = this.getField("Today");
    f.value = util.printd("mm/dd/yyyy", new Date());

    Save the file: This document should now print with today's date.
    The text boxes can be copied to multiple documents, but the javascript may need to be copied to each one (sometimes it seems to happen by itself, other times not, and I haven't worked out why)

    (I did most of my work in Ver 5, so there may now be easier ways...?)
    DimitriM
    Inspiring
    November 10, 2005
    Dave,

    you have it exactly right about creating the text fields, and it is possible to create the text fields programmtically from a batch process.

    Include a doc.addField() statement in the JavaScript in your batch process. Make sure you add the field before you set the document script.

    Dimitri
    WindJack Solutions
    www.windjack.com
    Participating Frequently
    November 10, 2005
    Hi Dimitri -

    I am following what you are suggesting. As I understand it, I first need to create a text field in each PDF, then add a document level or page level JS that populates the text field with the dynamic date.

    I have done this successfully on single once-page documents...no problem. But I have hundreds of documents (each has with multiple pages). So can these 2 things be performed using a batch command? If so...how?

    Thanks,
    Dave
    Participant
    November 10, 2005
    Hi Steve,

    I need this functionality, too, but I have no idea how to implement it in my document (I'm using the german version of Acrobat 6.0).
    Would you please post a step-by-step instruction including the needed javascript?

    I'm new to both Acrobat and JavaScript...

    Many thanks!

    Sven
    steve_foxall
    Participating Frequently
    November 10, 2005
    As an alternative to Headers & Footers, you could add your message 'Date Printed' to a button that is 'invisible but prints' and the date to a similar button next to it (this one would have to run the javascript inserting the current date) That way the message isn't visible to users viewing the document on screen, but will be there whenever anyone prints it.
    Can email example if helpful.
    DimitriM
    Inspiring
    November 10, 2005
    Dave,

    if you used the footer command in Acrobat then yes- it always puts the date the batch was run on the document, not the current date. The JavaScript method using the util.printd command will do what you want. You have to place a command in a document script that loads the current date into your date field. The documents scripts are executed when the document opens.

    To add a document script using a batch process use the Run A JavaScript batch command with the following statement-

    this.addScript("myscript",strScript);

    where strScript is the text for the script you want added to the document.

    Hope that helps.

    Dimitri
    WindJack Solutions
    www.windjack.com
    Participating Frequently
    November 9, 2005
    I got around my compliance department, but maybe I misinderstand what this function does.

    I batched 100+ document yesterday. The date inserted into the footer was 11/08/2005.

    So today, I open one of the documents and it still says 11/8/2005. I want the CURRENT DATE always displayed at the bottom of the documents.

    Will this batch command do that? To me it looks like it only puts the date the batch was run....