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?
42.6K
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
New Here ,
Nov 01, 2005 Nov 01, 2005
you can batch that: adv> batch> new sequence> name> select commands> add header & footer> chost it and say edit> add the date style you like and press ok.

then just run the batch.

hope that helps,
pat
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 01, 2005 Nov 01, 2005
Hey Pat -

That got me 95% there. However, for compliance reasons I must format the date like this: 01 NOV 2005. I don't see a formatting option for this.

Any ideas?
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 01, 2005 Nov 01, 2005
well you could add custom text and just type that date in the colum you want instead of inserting the auto date, but it looks like the auto date is limited to what you see.
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 01, 2005 Nov 01, 2005
I'm new to Acrobat, could you elaborate on how I might do what you are referring to?
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 01, 2005 Nov 01, 2005
well , esentially when you are editing your batch sequence & are in the headers and footers area, you can actually type custom text into the fields listed above. Just add the info you want in the orientation you want then go ahead and batch the files.
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 01, 2005 Nov 01, 2005
Okay, I follow that process, but that only works for static text as far as I can tell. I need to have the current date populate, but in the "01NOV2005" format.

Is there a way to get the current date in the headers/footers OTHER THAN the process you already told me about?
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
Engaged ,
Nov 02, 2005 Nov 02, 2005
Hi Dave,

I've played around with the headers/footers too. For the date style you need I think you are going to have to do this with JavaScript, or get your compliance department to change the accepted date format :)

Take a look at the util.printd command in the Acrobat JavaScript Reference doc.

Best of luck,

Dimitri
WindJack Solutions
www.windjack.com
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 09, 2005 Nov 09, 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....
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
Engaged ,
Nov 09, 2005 Nov 09, 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
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 ,
Nov 10, 2005 Nov 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.
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 10, 2005 Nov 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
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 10, 2005 Nov 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
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
Engaged ,
Nov 10, 2005 Nov 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
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 ,
Nov 10, 2005 Nov 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...?)
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 10, 2005 Nov 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
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
Engaged ,
Nov 10, 2005 Nov 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
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 10, 2005 Nov 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?
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 11, 2005 Nov 11, 2005
Reinhard -

I opened a PDF I made yesterday per your instructions, and the date at the bottom still says 10/nov/2005. Today is 11/Nov/2005. Why didn't the date change?

To re-iterate, I need the date displayed on all the PDFs to have the CURRENT DATE....not the date the PDF was made. Is there anyone who knows if this is possible? And if so...how do I do it?
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
Engaged ,
Nov 11, 2005 Nov 11, 2005
"Can you explain the [30,12, 100,28] ?"

Coords are calculation from the left lower corner. 30 = Difference to left Side; 12 = Diff. to bottom; 100 = length of Field; 28 are high of field, which has to be set according to "fd.textSize=8" = font high.

Play a little bit around with that. You need not center text, you can center the field. If you delete one field all fields will be deleted, because the have the same name.

"Why didn't the date change?"
new Date() delivers the actual date (not the production date). But it will be stored as value. Delete the field and run the macro new.

HTH, Reinhard
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 11, 2005 Nov 11, 2005
Reinhard -

Not sure what you mean - " Delete the field and run the macro new."

This is the script I am running. I made a test file with it yesterday and today is still says Document printed on 10/nov/2005.

What needs to be changed?

for (var p = 0; p < this.numPages; p++)
{
var fd = this.addField("Date", "text", p, [72,0, 540,16]);
fd.textSize=8;
fd.value = "Document printed on: " + util.printd("dd/mmm/yyyy", new Date());
fd.allignment = "right";
fd.fillColor = color.transparent;
fd.textColor = color.gray;
fd.borderColor = color.gray;
fd.readonly = true;
}
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
Engaged ,
Nov 11, 2005 Nov 11, 2005
" Delete the field and run the macro new."

You can simple use your formula (field) tool and choose edit -> delete.

Have to go into the weekend.

So long, Reinhard
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 11, 2005 Nov 11, 2005
Can anyone explain why this script is not producing a dynamic date?

Is producing a dynamic date even possible? Am I ttrying to do the impossible here?

for (var p = 0; p < this.numPages; p++) {
var fd = this.addField("Date", "text", p, [72,0, 540,16]);
fd.textSize=8;
fd.value = "Document printed on: " + util.printd("dd/mmm/yyyy", new Date());
fd.allignment = "center"; fd.fillColor = color.transparent;
fd.textColor = color.gray;
fd.borderColor = color.gray;
fd.readonly = true; }

Also - the text is not being centered in teh form field, even though the allignment parameter is set to center.
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 ,
Nov 11, 2005 Nov 11, 2005
> Can anyone explain why this script is not producing a dynamic date?

The script adds the date of the script run.
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 11, 2005 Nov 11, 2005
So is it even possible to do what I need to do?
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