Copy link to clipboard
Copied
Hi there, I have spent far too much time googling this and trying different things such as stamps but would like to know if there is a simple way to save a form field to use on multiple docs (I know how to duplicate across pages but not across docs!).
I add a form field to say "This document was printed on <today's date and time>"
Where today's date and time is a javascript that works it out the current date and time. I also add the same script to "will print" and "did print" to ensure it will give the most current on opening and printing.
It is a monotonous task to do when you have to add to hundreds of documents and I would like to know if there is a quick way to create the form and then apply it to as many docs as you need to (I can do it with applying a saved watermark to all open docs, so hoping I can do this too)
It would speed up my friday work no end!
Thanks for any help
Copy link to clipboard
Copied
You can use this code to add the field, and all of the scripts used for it:
var f = this.addField("Today", "text", 0, [222.6179962158203,775.823974609375,372.6180114746094,753.823974609375]);
f.readonly = true;
this.addScript("Today", "function updateToday() {var f = this.getField(\"Today\");f.value = \"Document printed on \" + util.printd(\"dd/mmm/yyyy HH:MM\", new Date());} updateToday();");
this.setAction("WillPrint", "updateToday();");
this.setAction("DidPrint", "updateToday();");
Copy link to clipboard
Copied
Do you want all the fields to be identical copies of each other?
If so, place the addField command in a a loop that iterates over all the page numbers, like this:
for (var p=0; p<this.numPages; p++) {
var f = this.addField("Today", "text", p, [222.6179962158203,775.823974609375,372.6180114746094,753.823974609375]);
f.readonly = true;
}
Copy link to clipboard
Copied
Hi
Can you tell us which Adobe application you're using so we can move the thread to the correct forum
Copy link to clipboard
Copied
Hi Sorry Yes Acrobat Pro DC, thank you
You need to ask program questions in the forum for the program you are using
To ask in the forum for your program please start at https://community.adobe.com/
Moving from Using the Community (which is about the forums) to the correct forum... Mod
Copy link to clipboard
Copied
Yes, this can be done in Acrobat Pro using an Action that executes a script that adds the field and set the document actions. Where on the page do you want the field to appear, and what should it look like? If you could share a sample page with the field it might be easier...
Copy link to clipboard
Copied
Hi there I have attached a PDF with the field applied at the top of the page (which is where I put it). (I have left the field so that it isn't read only in case you need to do anything).
Thank you so much for any help you can provide 🙂
Copy link to clipboard
Copied
You can use this code to add the field, and all of the scripts used for it:
var f = this.addField("Today", "text", 0, [222.6179962158203,775.823974609375,372.6180114746094,753.823974609375]);
f.readonly = true;
this.addScript("Today", "function updateToday() {var f = this.getField(\"Today\");f.value = \"Document printed on \" + util.printd(\"dd/mmm/yyyy HH:MM\", new Date());} updateToday();");
this.setAction("WillPrint", "updateToday();");
this.setAction("DidPrint", "updateToday();");
Copy link to clipboard
Copied
Thank you, please can you let me know what I need to do with this script? Is it in Action Wizard - where do I put it to make it work?
Thanks so much
Copy link to clipboard
Copied
Yes, in the Action Wizard. Create a new Action, add to it an Execute JavaScript command (make sure to untick the "Prompt Changes" check-box!) with this code, and then add a Save command after it, and then run the Action on your files.
Copy link to clipboard
Copied
That is great thank you so much it will save me so much time. Just one more question, if I need the positioning of the text box to be moved what do I do to the script to move it?
I'm assuming it has something to do with coordinates or something from the long number string in the script.
Copy link to clipboard
Copied
Guessing I take it from here
Copy link to clipboard
Copied
I changed the unit of measurement to points and tried replacing the numbers in your script with the numbers in the boxes, but it didn't work, probably because I don't know how to write scripts properly LOL
I am so very close, almost there, I also also need to add to the script to duplicate across all pages can that be done, otherwise I think it will mean I will still have to open up each document to durplicate the text field.,
Copy link to clipboard
Copied
Yes, you're almost there.
The coordinates need to be in the following order (using the Points units):
[left, top, right, bottom]
Copy link to clipboard
Copied
Thank you, and what do I need to add to the script to duplicate the text box across all pages 🙂
Sorry I don't ask for much do I LOL
Copy link to clipboard
Copied
Do you want all the fields to be identical copies of each other?
If so, place the addField command in a a loop that iterates over all the page numbers, like this:
for (var p=0; p<this.numPages; p++) {
var f = this.addField("Today", "text", p, [222.6179962158203,775.823974609375,372.6180114746094,753.823974609375]);
f.readonly = true;
}
Copy link to clipboard
Copied
Yes I do, thank you so much for your help, a long and monotonous task made much quicker. Really appreciated 🙂

