Skip to main content
Participating Frequently
November 1, 2005
Question

Add current date to PDF documents

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

    steve_foxall
    Participating Frequently
    June 4, 2007
    Hi GC;
    If you don't need the complexity of batch processing existing documents and insertion as a footer (but just want a dynamic date and warning text that only shows up on printing) check out #14 method.
    Participating Frequently
    June 4, 2007
    Thanks Dave for the quick response. I will take a look at #53. Appreciate it. GC
    Participating Frequently
    June 4, 2007
    Hey GC -

    I am still using Acrobat 7.0, but I can't imagine batch processing changed much. Step by step instructions for setting up the batch sequence and running it on 1 or more existing PDFs is directly above your last post...#53 I think.

    Good luck!
    Participating Frequently
    June 4, 2007
    Hi Dave:

    I am new to Adobe 8.0 Professional and JS. Like Susan I want to simply place a statement "Document is only valid on date" and automatically insert Today's date (anytime the document is printed).

    How do I get your code to work in Adobe 8.0. Your help is greatly appreciated.

    Thanks, GC
    Participating Frequently
    November 14, 2006
    Hi Susan,<br /><br />I feel your pain, it took me a month or more with a lot of help from Dimitri @ Windjack Solutions to get what I needed. It is certainly not as easy as it should be...and it is not something you can do manually - you need to use the batch processing feature.<br /><br />So....make your PDF (without any footer). Go to Advanced -> Batch Processing -> New Sequence. Then Select Commands -> Execute Javascript -> Edit, and paste in the following:<br /><br />- - - - - - - start code snippit - - - - - - -<br /><br />/* Put script title here */<br /><br /> // Check for existing field and make sure it's on the first page<br /> var strModName = "DocMessage";<br /> var ofield = this.getField("DocMessage");<br /><br /> // Create Field if it doesn't exist<br /><br /> if(ofield == null)<br /> {<br /> // Field is the width of the page, on the bottom of the page<br /> // and 40 points high (72pts/inch)<br /><br /> for(var i=0;i<this.numPages;i++)<br /> {<br /> var rectField = this.getPageBox("Crop",i);<br /> rectField[1] = rectField[3] + 14; // Set Top<br /> ofield = this.addField({cName: strModName,cFieldType: "text",<br /> nPageNum:i ,oCoords: rectField});<br /> ofield.alignment = "center"; //This is the text alignment of the field<br /> ofield.multiline = true;<br /> ofield.textSize = 8; <br /> ofield.textFont = "Arial";<br /> ofield.display = display.noView; //This is hidden on the page but printable to make viewable change to display.visible or noView<br /> ofield.readonly = true;<br /> }<br /> }<br /><br /> // Add Field to Document Script<br /> var strJS = 'var ofield = this.getField("DocMessage");';<br /> strJS += 'var theDate = (new Date((new Date()).valueOf() + 1000 * 60 * 60 * 24 * 14));';<br /> strJS += 'ofield.value = "PRINTED COPIES OF THIS DOCUMENT WILL EXPIRE AT MIDNIGHT ON";';<br /> strJS += 'ofield.value += " " + util.printd("ddmmmyyyy",theDate) + ". Do not use after this date.";';<br /> this.addScript("AddMessage",strJS);<br /><br />- - - - - - - end code snippit - - - - - - -<br /><br />the last number in the following line of code determines the dynamic date. In this case it is 14 days from the date printed:<br /><br />strJS += 'var theDate = (new Date((new Date()).valueOf() + 1000 * 60 * 60 * 24 * 14));';<br /><br />If, for example, you want the date to be 3 days from the date printed, change the 14 to a 3, ie:<br /><br />strJS += 'var theDate = (new Date((new Date()).valueOf() + 1000 * 60 * 60 * 24 * 3));';<br /><br />Now that you have the batch sequence set up, you go to Advanced -> Batch Processing, select the sequence you just made and click Run Sequence. Select your target PDF and click run sequence. Be advised, the default output option is to overwrite the existing file, so I advise you change the output options before running the batch sequence.<br /><br />That's it. Hope this is what you were looking for.
    Participant
    March 15, 2011

    I have tried the Java script message for the textbox added on the bottom of the page, described in #14, I had the printed date working however all the following pages formatting went wonky,

    I currently have some 200 PDF documents I need to add the Current date only visible upon printing to. I would like to handle as a batch, I looked at the example from #53. I am missing something as on the trial document nothing happened. I am very green to all of this javascript and I have only had the standard version of acrobat until last week.

    Please help!!

    Donna

    Participant
    November 14, 2006
    Cam anyone break this down for the layman? I created an Adobe docuemnt (Manual). I put the following text in the footer: PRINTED COPIES OF THIS DOCUMENT WILL EXPIRE AT MIDNIGHT ON:

    Now all I want to do is add a date that will change each day. Why isn't this simple feature in Adobe? I have Professional 7.0 with all the upgrades but I still can't figure it out.

    I have been banging my head on the desk for two days now to no avail.

    I hate to switch back to MS Word but at least they added "Autotext" which completes this function in one click.

    Any pointers or simple way's to get this done?

    Susan
    Participant
    June 23, 2006
    This is exactly the information I was looking for. We have drawings on our intranet that need to be 'watermarked' with a statement saying the drawing is controlled, or not controlled, and what the expiration date/time is. Thank you, Steve, for sending me the pages. That will help!

    We were adding the text fields in a batch via Visual Basic and the iSEDQuickPDF control, using a javascript not embedded in the document to determine what gets 'printed' on the pdf, but I think by putting the dynamic date in a field separate from the 'controlled', 'not controlled', etc text, it will be easier to work with.

    Thank you all, for your wonderful instructions!

    Julie
    Technical Services for Electronics, Inc.
    April 23, 2006
    Thanks Dave West,

    I am also trying to acheive the similar funtionality as you mentioned.
    I am not a PDF and Java expert.
    I have a situation, where I have to print the message at the top of every page "Printed on: d-mmm-yyyy" with current date from the system.
    Note: I want this message to printed only not to be displayed.

    I have acheived this, by using two Test fields, on static, the otherone dynamic with current date.
    I am using a JS to put current date in. I have put this JS in the Page Propertis/Action/When Page Open/Run JavaScript
    and it works.

    If you have solved your problem, please let me know otherwise, I can give you my technique. It is same as Steve foxall's but mine does not run in DocumentScripts. I was not able to run this in DocumentScripts. I dont know why.

    Thanks.

    Maqsood
    Thom Parker
    Community Expert
    Community Expert
    January 20, 2006
    To execute a line of code in the console window you put the cursor on the line and hit either "Ctrl-Enter" or the "Enter" key on the number key pad. You can execute part of a line or multiple lines by selecting the code and doing the same thing.

    Good Luck,
    Thom Parker
    WindJack Solutions
    www.windjack.com
    Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
    Participating Frequently
    January 20, 2006
    Hi Thom -

    That did the trick - the script works great now. Thanks to you and Dimitri for all your help with this.

    I have tried using the debugger - I paste the code into the console window, but from there nothing happens. I don't see a way to actually "run" a script.... It won't let me paste anything in the Script window...so I guess I'm missing something...