ADOBE ACROBAT WINDOWS 72 CONFUSED AND DAZED
From: Gerry_Heinemann@no-spam
Subject: Confused and Dazed
Date: Thu, 1 Apr 2004 09:12:46 -0800


Been staring at this and don't know how to solve it.

Using:
Acrobat 5.05
Windows NT 4.0 SP6
P4 2.0 GHz 256 MB RAM
I'm trying to use the "Doc/Open" event to add the current date and an expiry date to the bottom of a document each time it's opened.


I can do it manually by going to the Tools - Javascript - Document Javascripts, adding a script name and adding the following code:


var numpage = this.numPages;
var now = new Date();
var days = 3;
/*
variable "days" is the number of days till expiry of the document * / var date_num = now.valueOf();
date_num += 1000 * 60 * 60 * 24 * days;
var expire_date = new Date(date_num);

for (var i=0; i < numpage; i++) { var f = this.addField("Expiry", "text", i, [30,40,220,13]); f.userName="Date Opened and Date Expired"; f.display = display.noView; f.textsize = 10; f.borderStyle = border.s; f.alignment = "left"; f.multiline = true; f.value = ("Printed on: "+util.printd("yyyy-mm-dd",new Date())+" \nExpires on: "+ util.printd("yyyy-mm-dd", expire_date)); }


What I want to do is have a menu item added using:

app.addMenuItem({cName: "Expire", cUser: "Add Doc Expiry Date", cParent: "Document", nPos: 30, cExec: "Expiry();", cEnable: "event.rc = app.activeDocs.length > 0" });


and wrap the above code as the function ("Expiry()") so that the user can select the menu item "Add Doc Expiry Date" to add this code to the open document.


This does not add it to the document level but to the field "Exipry" and it's only run once.


This is where I'm stuck.

How do I get app.addMenuItem to add the above code to the Document Level javascript of the document currently open so it's run each time the document is opened.


Gerry

From: Gerry_Heinemann@no-spam
Subject: Re: Confused and Dazed
Date: Fri, 2 Apr 2004 05:58:19 -0800

The just of the above question is how do I add a document level javascript, using the "Doc/Open" event as a trigger, to an open document using a Javascript?

Gerry