How to create dynamic PDF stamp?
Copy link to clipboard
Copied
We are trying to setup a dynamic stamp in Adobe Acrobat Standard DC 2015. We have created the file and the stamp is working as a static stamp. We would like to automatically insert the current date and open a user input window to enter a line of characters. I don't have any javascript experience and we have been trying to piece together how to do this from articles on the web. What we have so far is
var cDate = util.printd("dd/mm/yyyy", new Date());
var cAsk = "Payment Method" ;
var cTitle = "Payment Method: ";
if(event.source.forReal && (event.source.stampName == "#paid_stamp"))
{
var cMsg = app.response(cAsk, cTitle);
event.value = cMsg;
event.source.source.info.exhibit = cMsg;
}
We have gone into Prepare Form and put this into the Text Field Properties / Calculate tab of the first text filed (the date field). Does anyone have a step-by-step guide on how to make this work. It seems very complicated for such a simple requirement.
Copy link to clipboard
Copied
You must use the correct stamp name:
Copy link to clipboard
Copied
Thanks for your reply. I did look at this article but it refers to Adobe Acrobat XI and so much of the explanation does not work with Adobe Acrobat Standard DC 2015. The concepts may be similar but how to make them work is the problem I am having.
I looked at Adobe Acrobat DC Dynamic Stamp Tutorial - YouTube which is a more up to date look at dynamic stamps. But I think he is using the 'Pro' version because the debugging tool is not in my version. This means I can't find where the stamp template is stored using app.getPath(“user”, “stamps”); I can't find it in C:\Program Files (x86)\Adobe\Acrobat 2015\Acrobat\plug_ins\Annotations\Stamps\ENU or in C:\Users\Patrick\Adobe Stamp.
So I then tried to create the template using Organise Pages / More / Page Templates method he describes, but I can't find the template file name to work on the stamp file.
Can this be done in Acrobat Standard. Such a lot of mucking around for such a simple thing; add the date and a text filed.
Copy link to clipboard
Copied
With ctrl-j you can access the console.
Copy link to clipboard
Copied
In Acrobat Standard, the JavaScript console is hidden, and you need to install a folder level script to make it accessible. See here for such a script: Free Acrobat Automation Tools - look for the "Reader JavaScript Console Window" script.
Copy link to clipboard
Copied
What an appalling little tool. It runs once and then crashes and can't be used again unless you restart the whole program.
I ran var cDate = util.printd("dd/mm/yyyy", new Date()); and it didn't show the date, I can't remember the error message because the debugger wouldn't run the code again without restarting the whole program.
I then ran this.selectedAnnots[0].AP which came up with nothing...arrrh!!!
This is really a dog of a system, it is too complex and convoluted to do anything with in a reasonable time frame and without having to buy a book and learn javascript??? WTF?? It is just a date and a text field....I am sure that very few people are using it and unless it is simplified so people can quickly and efficiently use it will continue to be ignored.
Thanks for trying, it is nothing personal, but Adobe need to look at how the users can quickly use the program to make their workflow simpler not more complicated.
Copy link to clipboard
Copied
Did you have the annotation selected or highlighted before running the code?
There are also other scripts you could use to get the stamp's name. If there is only one annotation in the PDF you could just list all the annotations' names and since there is only one annotation the name will be the stamp's name.
to
The following script can be run from the JavaScript console and will list all the annotations of any type along with the internal name of the annotation:
this.syncAnnotScan(); // update for annotaions array;
annots = this.getAnnots({nSortBy:ANSB_Author}); // get updated array of annotations;
console.println("Number of annotations: " + annots.length); // number of annotations;
var oAnnot; // for single annotation;
for(var i = 0; i < annots.length; i++)
{
console.println(i + " type: " + annots.type + " name: " +annots.name);
} // end for annots length;
Note this code updates the list or array of available annotations to include and newly added annotations before the running of the code. You will be interested in the annotations with a type of "stamp".
Dynamic stamps are quite complex and I have had to read the documentation and article several times to understand the subtleties of the dynamic stamp annotation and I am sure there is still more I can learn.
Copy link to clipboard
Copied
You probably don't want or need this line:
event.source.source.info.exhibit = cMsg;
Copy link to clipboard
Copied
Just to elaborate on George's warning: The stamp with this line will work in Adobe Acrobat, but will not work in the free Adobe Reader.

