Javascript to alert PDF update after a certain date
Sometimes is necessary to create pdf documents with an expiration date
or with a warning after a certain date.
Adobe have a professional server solution called 'LiveCycle Rights
Management ES', to respond to this requirement and many others.
The follow javascript simply test, on the event 'page open', if the
current system date is major or equal to a defined date and in this case
popup an alert.
//----------------------------------------------------------------------
// --- start edit expiration date ---
var lastDay=28
var lastMonth=5
var lastYear=2009
// --- end edit expiration date ---
var sessione
var today=new Date();
var myDate=new Date();
lastMonth=lastMonth-1;
myDate.setFullYear(lastYear,lastMonth,lastDay);
if (myDate<=today && sessione!=1)
{
app.alert("The current document may be up to date\r\nverify a new
version on http://www.root-path.net", 1, 0, "ALERT");
sessione=1;
}
//---------------------------------------------------------------------
To set a page action you must have a professional version of Adobe
Acrobat and follow this steps:
1) set the appropriate start and end date in the previus script (first
three lines)
2) open the pdf document with adobe acrobat professional and go to the
first page
3) choose 'Document' menù and then 'set page action'
4) on 'page open' event chooe 'Add' and the JavaScript action
5) modify the javascript copying the previus script
6) save the document
or with a warning after a certain date.
Adobe have a professional server solution called 'LiveCycle Rights
Management ES', to respond to this requirement and many others.
The follow javascript simply test, on the event 'page open', if the
current system date is major or equal to a defined date and in this case
popup an alert.
//----------------------------------------------------------------------
// --- start edit expiration date ---
var lastDay=28
var lastMonth=5
var lastYear=2009
// --- end edit expiration date ---
var sessione
var today=new Date();
var myDate=new Date();
lastMonth=lastMonth-1;
myDate.setFullYear(lastYear,lastMonth,lastDay);
if (myDate<=today && sessione!=1)
{
app.alert("The current document may be up to date\r\nverify a new
version on http://www.root-path.net", 1, 0, "ALERT");
sessione=1;
}
//---------------------------------------------------------------------
To set a page action you must have a professional version of Adobe
Acrobat and follow this steps:
1) set the appropriate start and end date in the previus script (first
three lines)
2) open the pdf document with adobe acrobat professional and go to the
first page
3) choose 'Document' menù and then 'set page action'
4) on 'page open' event chooe 'Add' and the JavaScript action
5) modify the javascript copying the previus script
6) save the document
Comments