I have added the following code in acrobat 9 javascript folder to add a filed named xftDate:
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)"});
var inch = 72;
for (var p = 0; p < this.numPages; p++) {
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
function SetFooter(ARG)
{
var re = /.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re,"")+".pdf";
var Path = this.path;
var AcDate = new Date();
for (var p = 0; p < this.numPages; p++)
{
if (ARG==1 || ARG==3) {var fd = this.addField("xftDate", "text", p, aRect )};
fd.textSize=6; fd.value = util.printd("yyyy/mmm/dd, HH:MM", AcDate) + " (" + FileNM +")"; }
if (ARG==2 || ARG==3){var fp = this.addField(String("xftPage"+p+1), "text", p, [350,15,300,30]);
fp.textSize=6; fp.value = "Page: " + String(p+1)+ "/" + this.numPages; }
} }
function RemoveFooter(ARG)
{
if (ARG==1 || ARG==3) {var x = this.removeField("xftDate");}
if (ARG==2 || ARG==3) {for (var p = 0; p < this.numPages; p++)
{
var x = this.removeField(String("xftPage"+p+1)); }
} }
***I have added this code in the javascript folder in reader 9 hoping to fill the xftDate field created in PRO 9 but I am getting the following error:
this.getField is not a function
1:Folder-Level:App:Document.js
var fld = this.getField("xftDate"); fld.textFont = font.HelvB;
var d = new Date();
var t = new Date();
fld.value = ("Destroy 24 hrs. after print date: " + util.printd("mm/dd/yyyy ", d) + util.printd("hh:MM tt", t));
Upon starting Reader?
Opening a PDf in Reader?
I would have placed the code you placed in the Reader JavaScript folder in the 'Will Print' action of the PDF you added the 'xftDate' field to. You can add more code to your button to add the code to your button and use the 'setAction' method to set the 'WillPint' trigger.
George Kaiser