Copy link to clipboard
Copied
Adobe XI
Windows 7
I am working on a stamp that when selected presents a dialogue the user fills out then applies responses to the text-fields on the stamp and places it in the doc. Here is my code for the stamp. I saved script as a "Custom Calculation script in field 1" see pictured mock up of the stamp.
The Field1 calculation script is below. It works fine within the stamp file but when trying to apply the stamp to a doc the dialogue does not activate. My issue Im sure is in the bolded code at the bottom. Thom Parker makes use of event.source.source.info.DocumentState to modify the fields. I can not find any documentation on this or the source.source that he discusses here https://acrobatusers.com/tutorials/dynamic_stamp_secrets‌. But he is using app.response which is simpler than multi-fields here. Any help and explanation is appreciated.
var oDlg = {
strField1: "",
initialize: function(dialog) {
dialog.load({"fld1":this.strField1});
},
strField2: "",
initialize: function(dialog) {
dialog.load({"fld2":this.strField2});
},
strField3: "",
initialize: function(dialog) {
dialog.load({"fld3":this.strField3});
},
commit: function(dialog) {
var data = dialog.store();
this.strField1 = data[ "fld1"];
this.strField2 = data[ "fld2"];
this.strField3 = data[ "fld3"];
},
description: {
name: "Test Dialog",
elements: [
{
type: "view",
elements: [
{
name: "Field 1:",
type: "static_text",
},
{
item_id: "fld1",
type: "edit_text",
char_width: 15
},
{
name: "Field 2:",
type: "static_text",
},
{
item_id: "fld2",
type: "edit_text",
char_width: 15
},
{
name: "Field 3:",
type: "static_text",
},
{
item_id: "fld3",
type: "edit_text",
char_width: 15
},
{
type: "ok_cancel",
},
]
},
]
}
};
if(event.source.forReal && (event.source.stampName == "#1MmYgzwIvYfvvgcFEWQfSA"))
{
var output1 = this.getField("Text1");
var output2 = this.getField("Text2");
var output3 = this.getField("Text3");
if( "ok" == app.execDialog(oDlg)) {
output1.value = oDlg.strField1;
output2.value = oDlg.strField2;
output3.value = oDlg.strField3;
}
}
Instead of "#1MmYgzwIvYfvvgcFEWQfSA", you need to use the first part of the template name you've used. When you create a stamp, it is actually a page template, and every page template has a name. Usually you call it something like "Template1", or "Additonaflinformation", or whatever describes the template page. For a stamp, you have to follow a certain pattern. The template name is always "InternalStampName=Stamp Name the User Sees". For dynamic stamps, you also add a "#" at the beginning (so th
...Copy link to clipboard
Copied
Forget about event.source.source.info and all of that. You don't need it, unless you want to apply the values to the metadata of the file.
What you do need to make sure is that the stampName value is correct. To do it apply the stamp, even if it's not working correctly yet, to some file, and then select the stamp annotation you just added and run this code from the JS-Console:
this.selectedAnnots[0].AP
It will print out the value you need to use as the stampName in your code.
One other thing, although it's minor, is that if the code above is the custom calculation script of Text1 then replace this line:
output1.value = oDlg.strField1;
With:
event.value = oDlg.strField1;
Copy link to clipboard
Copied
Instead of "#1MmYgzwIvYfvvgcFEWQfSA", you need to use the first part of the template name you've used. When you create a stamp, it is actually a page template, and every page template has a name. Usually you call it something like "Template1", or "Additonaflinformation", or whatever describes the template page. For a stamp, you have to follow a certain pattern. The template name is always "InternalStampName=Stamp Name the User Sees". For dynamic stamps, you also add a "#" at the beginning (so that your internal name becomes e.g. "#InternalStampName") - this hash mark indicates to Acrobat that the stamp scripts need to be run every time the stamp is placed.
So, when you created the page template, what name did you use? Use that in your script and it should work.
Copy link to clipboard
Copied
You are correct. Code is fine. I was not creating the stamp files correctly and after redoing it I was able to get the correct stamp name and get the stamp working. Thanks for the help.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now