agsingh2000
asked on
How do I put a timestamp on a PDF file each time it is printed..?
i want to fire a event, when ever there a print there should be a date stamp. I think this can be done using a javascript. though i found a code for it i dont know how to call every time a document is printed.
thnx
thnx
Which version of Acrobat do you have?
ASKER
its version 5
Open the PDF file that you want to print the time stamp on.
In Acrobat 5 select the menu "Tools>JavaScript>Set Document Actions". This will bring up the "Document Actions" dialog. Here you can assign JavaScript programs to certain events (Document Will Close, Document Will Save, Document Did Save, Document Will Print and Document Did Print).
Select the "Document Will Print" entry and click on "Edit". In the editor, paste the following script:
for (var i = 0; i < this.numPages; i++)
{
// get the crop box for the page
var aRect = this.getPageBox("Media", i);
var width = aRect[2] - aRect[0];
var height = aRect[1] - aRect[3];
// create the form fields for all pages
var fieldPos = [width-144, height-72, width, height];
var f = this.addField(String("Rece ived"), "text", i, fieldPos);
f.textSize = 12;
f.textColor = color.blue;
f.fillColor = color.transparent;
f.textFont = font.HelvB;
f.borderStyle = border.s;
f.strokeColor = color.transparent;
f.value = stamp;
}
Then select "Document Did Print", and add the following script:
// remove today's date
for (var i=0; i<this.numPages; i++)
{
this.removeField("PrintedD ate");
}
In Acrobat 5 select the menu "Tools>JavaScript>Set Document Actions". This will bring up the "Document Actions" dialog. Here you can assign JavaScript programs to certain events (Document Will Close, Document Will Save, Document Did Save, Document Will Print and Document Did Print).
Select the "Document Will Print" entry and click on "Edit". In the editor, paste the following script:
for (var i = 0; i < this.numPages; i++)
{
// get the crop box for the page
var aRect = this.getPageBox("Media", i);
var width = aRect[2] - aRect[0];
var height = aRect[1] - aRect[3];
// create the form fields for all pages
var fieldPos = [width-144, height-72, width, height];
var f = this.addField(String("Rece
f.textSize = 12;
f.textColor = color.blue;
f.fillColor = color.transparent;
f.textFont = font.HelvB;
f.borderStyle = border.s;
f.strokeColor = color.transparent;
f.value = stamp;
}
Then select "Document Did Print", and add the following script:
// remove today's date
for (var i=0; i<this.numPages; i++)
{
this.removeField("PrintedD
}
ASKER
i have a similar code, but the problem is i dont want the users to always change the settingsin acrobat reader. Can this be done in some way that its automatic. So irrespetive of pdf document when ever there is a print even this code is fired.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does this answer your question?
ASKER
not exactly. I had the similar code that you gave me. But it seems that what i want cannot be achieved by javascript.
i am giving you the points for letting me know.
i am giving you the points for letting me know.