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

Add current date to PDF documents

New Here ,
Nov 01, 2005 Nov 01, 2005
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?
43.0K
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
replies 128 Replies 128
Guest
Apr 23, 2006 Apr 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
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 ,
Jun 23, 2006 Jun 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.
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 ,
Nov 14, 2006 Nov 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
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 ,
Nov 14, 2006 Nov 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.
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 15, 2011 Mar 15, 2011
LATEST

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

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 ,
Jun 04, 2007 Jun 04, 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
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 ,
Jun 04, 2007 Jun 04, 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!
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 ,
Jun 04, 2007 Jun 04, 2007
Thanks Dave for the quick response. I will take a look at #53. Appreciate it. GC
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
Contributor ,
Jun 04, 2007 Jun 04, 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.
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 ,
Jun 04, 2007 Jun 04, 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
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 ,
Jun 04, 2007 Jun 04, 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...
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 ,
Jun 04, 2007 Jun 04, 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
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
Contributor ,
Jun 05, 2007 Jun 05, 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!)
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 ,
Jun 15, 2007 Jun 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
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
Contributor ,
Jun 15, 2007 Jun 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?
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 ,
Sep 16, 2007 Sep 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.
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
Community Expert ,
Sep 17, 2007 Sep 17, 2007
You must add the text field at the top of the page.
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 ,
Sep 17, 2007 Sep 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);
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 ,
Sep 17, 2007 Sep 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
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 ,
Sep 17, 2007 Sep 17, 2007
// 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); // get page size quads<br />/* elements of quad array<br />[0] - lower left x; [1] - lower left y <br />[2] - upper right x; [3] - upper right y<br />*/<br />rectField[2] = rectField[2] - 14; // Place field 14 points from upper right height<br />ofield = this.addField({cName: strModName,cFieldType: "text", nPageNum:i ,oCoords: rectField});<br />ofield.alignment = "center"; //This is the text alignment of the field <br />ofield.multiline = true; 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 ofield.readonly = true; <br />} // end for numPages loop <br /><br />} // end create field<br /><br />// Add update upon open to Document Script <br /> var strJS = 'var ofield = this.getField("DocMessage");'; <br /> strJS += 'ofield.value = "Intellectual Property of My Company - CONFIDENTIAL. ";';<br /> strJS += 'var oToday = new Date();';<br /> strJS += 'ofield.value += " Document printed " + util.printd("dd mmm yyyy", new Date(oToday,getFullYear(), oToday.getMonth(), (oToday.getDate() + 14) ) ) + ".";'; <br /> this.addScript("AddMessage",strJS);
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 ,
Dec 11, 2007 Dec 11, 2007
Hi,
Even i am having a similar requirment. I have a document where i have added a form field (name: Today) and a Javascript just to assign the value of current system date to this value and show this date when i print the document. everything is fine but when i close the documnet, adobe is prompting to save the document. how can i avoid this? because, printing the system is done background and the user doesn't know it. but the user will be surprised when he see that adobe asking to save the PDF document which he is not aware of changed anything.

any ideas?

thanks,
Mahesh
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 ,
Dec 11, 2007 Dec 11, 2007
In the script that sets the current date add:

this.dirty = false; // prevent save prompt

to the end of the script to clear the docuemnt variable that tracks if any changes have been made.
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
Contributor ,
Dec 11, 2007 Dec 11, 2007
mah*****
If your users are only using Reader they won't get the prompt.

Geo
Nevertheless, it drives me mad too (using Acrobat Pro) so that bit of code is a little gold nugget...Thank-you!
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 ,
Dec 12, 2007 Dec 12, 2007
thanks alot guys. it worked like charm...
i love this forum...
gr8!!!

Mahesh
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 ,
Dec 13, 2007 Dec 13, 2007
Hi Guys,
I am having one more questions.
In our company 90% of them use Acrobat Standard 7 and i believe they will have option to edit the Javascript which i have written. if that is possible then, how can i make that not happen.
because, i will creating the PDF and publishing to our internal website and the user community will download it and print it and use it. If i cannot avoid changing this javascript, any techie user can modify and change and this may create problems.

Any ideas?

thanks,
Mahesh
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