These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Applying Dates to a PDF

patrickd
Registered: Feb 6 2008
Posts: 16
Answered

My company has a need to apply dates of printing to documents and have these dates show up on the document when they are printed. We initially used the date command on the footers but this date only applies to the date that the command was applied to the document. We need a date to be displayed that defines the current date when the document gets printed.

My Product Information:
Acrobat Pro 8.1.2, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
You can use the "Will Print" action with JavaScript to build the text string to insert into the footer and insert the footer before printing.

George Kaiser

patrickd
Registered: Feb 6 2008
Posts: 16
Can this text string be applied to the document to show the date whenever the doucment is printed? Such as 3 months down the road?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Yes,

Sample WillPrint action using the water mark from text to add the footer text:

var oNow = new Date(); // get JavaScript date Time object
var sNowDate = util.printf("mmm d, yyyy", oNow); // format current date into string like "Jan 1, 2008"
var sTextFooter = "Printed: " + sNowDate; // build string for footer.

// may have to provide code to perform the following code on a page by page basis if the PDF has different sized pages.

// get page size
var aRect = this.getPageBox("Media");
var height = aRect[1] - aRect[3];

// add watermark as a footer
this.addWatermarkFromText({
cText: sTextFooter,
nTextAlign: app.constants.align.right,
nHorizAlign: app.constants.align.right,
nVertAlign: app.constants.align.top,
nHorizValue: -36, nVertValue: -(height - 36)
});

George Kaiser