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

Adding dynamic date to PDF document

JSP
Registered: Jun 22 2010
Posts: 3

I am currently using Acrobat 5 for document creation. On the floor the 9.0 Reader will be used for viewing the document. I am very much a layman when it comes to javascript but was asked to create a simplier way to attach a date to a saved PDF document for viewing on the floor giving a 24 hr expiration from print date. I will be creating the document. I have created some script, listed below, from various sources adding a menu option, but the setAction is not a function of 5 and I am not finding anything else I could use in its place. Please offer some guidance.

app.addSubMenu({ cName: "Footer",cUser: "Set/Remove Footer", cParent: "File", nPos: 20 });

app.addMenuItem({ cName: "Set Date Time (Filename)", cParent: "Footer", cExec:

"SetFooter(1)"});

app.addMenuItem({ cName: "-------------------------------", cParent: "Footer",cExec: "{}"});

app.addMenuItem({ cName: "Remove Date Time (Filename)", cParent: "Footer", cExec:

"RemoveFooter(1)"});

function SetFooter(ARG)
{
var re = /.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re,"")+".pdf";
var Path = this.path;
var AcDate = new Date();
var inch = 72;
for (var p = 0; p < this.numPages; p++)

{

if (ARG==1) {
var aRect = this.getPageBox( {nPage: p} );
aRect[0] += .25*inch; // position rectangle (.5 inch, .5 inch)
aRect[2] = aRect[0]+5.5*inch; // from upper left hand corner of page.
aRect[1] -= .25*inch; // Make it .5 inch wide
aRect[3] = aRect[1] - 35; // and 24 points high

var fd = this.addField("date", "text", p, aRect );

fd.textFont=font.HelvB;

// Add WillPrint script
// set the text for the willPrint JS script action
var myWillPrintScript = 'var sPrintText = \"Destroy 24 hrs. after print date: \" + util.printd(\"mmm dd, yyyy\",

new Date()) + \" at \" + util.printd(\"HH:MM\",new Date());\\n'
myWillPrintScript += 'this.addWatermarkFromText({cText: sPrintText, nFontSize: 12,

bOnScreen: false, bOnPrint: true, nTextAlign: 2, nHorizAlign: 2, nVertAlign: 0, nHorizValue:

-52, nVertValue: +375 });\\n'
// set the WillPrint action
this.setAction({cTrigger: "WillSave", cScript: myWillPrintScript});
}

} }

function RemoveFooter(ARG)
{

if (ARG==1 || ARG==3) {var x = this.removeField("date");}

if (ARG==2 || ARG==3) {for (var p = 0; p < this.numPages; p++)

{

var x = this.removeField(String("xftPage"+p+1)); }

} }

My Product Information:
Acrobat Standard 5.x or older, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
There's nothing much to do, I'm afraid (except for upgrading, of course).
This command simply is not available on version 5.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com