Copy link to clipboard
Copied
I'm trying the below code to get a stamp with the multiple input. Based on the selection of option buttons, I require the stamp to be updated. I'm unable to find the error. Could someone help pl.
OK, that's fine.
I think the issue is that you defined the dialog object after the code where you're calling it. You should move the definition of DiaBox to the top of the code.
Copy link to clipboard
Copied
if(event.source.forReal && (event.source.stampName == "#pfP__PjJ7SwG7RRWsGspWA"))
{
if ("ok" == app.execDialog(DiaBox))
{
this.getField("Approved - Submit Final Copies").checkThisBox(0, DiaBox.bChk1);
this.getField("Approved as commented - Resubmit").checkThisBox(0, DiaBox.bChk2);
this.getField("Not Approved - Resubmit").checkThisBox(0, DiaBox.bChk3);
this.getField("Cleared for Manufacture").checkThisBox(0, DiaBox.bChk4);
this.getField("For Information").checkThisBox(0, DiaBox.bChk5);
var cMsg = DiaBox.byName;
event.value = "Remarks # " + cMsg;
event.source.source.info.exhibit = cMsg;
}
}
var DiaBox =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
bChk1:true,
bChk2:false,
bChk3:false,
bChk4:false,
bChk5:false,
stredt1:"",
initialize: function(dialog)
{
var dlgInit =
{
"Chk1": this.bChk1,
"Chk2": this.bChk2,
"Chk3": this.bChk3,
"Chk4": this.bChk4,
"Chk5": this.bChk5,
"Name": this.stredt1,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.bChk1 = oRslt["Chk1"];
this.bChk2 = oRslt["Chk2"];
this.bChk3 = oRslt["Chk3"];
this.bChk4 = oRslt["Chk4"];
this.bChk5 = oRslt["Chk5"];
this.byName = oRslt["Name"];
},
description:
{
name: "Stamp",
elements:
[
{
type: "view", elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Please select the review category:",
width: 152,
height: 23,
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "radio",
item_id: "Chk1",
group_id: "rado",
name: "Approved - Submit Final Copies",
},
{
type: "radio",
item_id: "Chk2",
group_id: "rado",
name: "Approved as commented - Resubmit",
},
{
type: "radio",
item_id: "Chk3",
group_id: "rado",
name: "Not Approved - Resubmit",
},
{
type: "radio",
item_id: "Chk4",
group_id: "rado",
name: "Cleared for Manufacture",
},
{
type: "radio",
item_id: "Chk5",
group_id: "rado",
name: "For Information",
},
{ type: "edit_text",
item_id: "Name",
height: 23,
char_width: 20,
char_height: 10,
alignment: "align_center",
name: "Enter Initials",
}
]
},
{
type: "ok_cancel",
},
]
},
]
}
};
Copy link to clipboard
Copied
The above code is working only if my source stamp file is open first before the pdf in which I want to stamp is open. if the source stamp file is not open, the pop up box for input is not opening! it directly applies the seal on PDF without taking the user input
Copy link to clipboard
Copied
Where did you place this code? Are you sure you're using the correct stampName value?
Copy link to clipboard
Copied
Yes! I have rechecked the stamp name. and I have placed the code in custom calculation script of one text box... textbox2.
Copy link to clipboard
Copied
Sorry for insisting, but this is crucial... How did you check the stamp name?
Copy link to clipboard
Copied
I placed the stamp on PDF and ... in console I gave the this.selectedAnnots[0].AP ....
this is the stamp name
#pfP__PjJ7SwG7RRWsGspWA ...
Copy link to clipboard
Copied
OK, that's fine.
I think the issue is that you defined the dialog object after the code where you're calling it. You should move the definition of DiaBox to the top of the code.
Copy link to clipboard
Copied
Thank you soo much, it worked when I changed the order!!! cool
Copy link to clipboard
Copied
So the final code that worked....
var DiaBox =
{
result:"cancel",
DoDialog: function(){return app.execDialog(this);},
bChk1:false,
bChk2:false,
bChk3:false,
bChk4:false,
bChk5:false,
stredt1:"",
initialize: function(dialog)
{
var dlgInit =
{
"Opt1": this.bChk1,
"Opt2": this.bChk2,
"Opt3": this.bChk3,
"Opt4": this.bChk4,
"Opt5": this.bChk5,
"Name": this.stredt1,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.bChk1 = oRslt["Opt1"];
this.bChk2 = oRslt["Opt2"];
this.bChk3 = oRslt["Opt3"];
this.bChk4 = oRslt["Opt4"];
this.bChk5 = oRslt["Opt5"];
this.byName = oRslt["Name"];
},
description:
{
name: "Stamp",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Please select the review category:",
width: 152,
height: 23,
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "radio",
item_id: "Opt1",
group_id: "rado",
name: "Approved - Submit Final Copies",
},
{
type: "radio",
item_id: "Opt2",
group_id: "rado",
name: "Approved as commented - Resubmit",
},
{
type: "radio",
item_id: "Opt3",
group_id: "rado",
name: "Not Approved - Resubmit",
},
{
type: "radio",
item_id: "Opt4",
group_id: "rado",
name: "Cleared for Manufacture",
},
{
type: "radio",
item_id: "Opt5",
group_id: "rado",
name: "For Information",
},
{
type: "edit_text",
item_id: "Name",
height: 35,
char_width: 20,
char_height: 10,
alignment: "align_center",
name: "Enter Comments",
}
]
},
{
type: "gap", //Add a small vertical gap between
height: 10 //..radio fields and buttons
},
{
type: "ok_cancel",
},
]
},
]
}
};
if(event.source.forReal && (event.source.stampName == "#pfP__PjJ7SwG7RRWsGspWA"))
{
if ("ok" == app.execDialog(DiaBox))
{
this.getField("Text3").value = ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name);
this.getField("Text1").value = util.printd("h:MM tt,dd-mmm-yyyy", new Date());
this.getField("cbx1").checkThisBox(0, DiaBox.bChk1);
this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);
this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);
this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);
this.getField("cbx5").checkThisBox(0, DiaBox.bChk5);
console.println("Success1");
var cMsg = DiaBox.byName;
event.value = "Comment # " + cMsg;
event.source.source.info.exhibit = cMsg;
}
}
Copy link to clipboard
Copied
I tried to follow this solution but mine doesn't populate the radio button selection onto the actual stamp. It will be print the info on By: and Date: but the rest will not populated. Please help. My code is below.
var DiaBox =
{
result:"cancel",
DoDialog: function()
{return app.execDialog(this);
},
bChk1:false,
bChk2:false,
bChk3:false,
bChk4:false,
stredt1:"",
initialize: function(dialog)
{
var dlgInit =
{
"Choice1": this.bChk1,
"Choice2": this.bChk2,
"Choice3": this.bChk3,
"Choice4": this.bChk4,
"Comment": this.stredt1,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var results = dialog.store();
this.bChk1 = results["Choice1"];
this.bChk2 = results["Choice2"];
this.bChk3 = results["Choice3"];
this.bChk4 = results["Choice4"];
this.byName = results["Name"];
},
description:
{
name: "stamp1",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Please select the review category:",
width: 152,
height: 23,
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "radio",
item_id: "Choice1",
group_id: "Group1",
name: "Reviewed",
},
{
type: "radio",
item_id: "Choice2",
group_id: "Group1",
name: "Reviewed with changes noted",
},
{
type: "radio",
item_id: "Choice3",
group_id: "Group1",
name: "Revise and Resubmit",
},
{
type: "radio",
item_id: "Choice4",
group_id: "Group1",
name: "Rejected",
},
{
type: "edit_text",
item_id: "Name",
height: 35,
char_width: 20,
char_height: 10,
alignment: "align_center",
name: "Enter Comments",
}
]
},
{
type: "gap", //Add a small vertical gap between
height: 10 //..radio fields and buttons
},
{
type: "ok_cancel",
},
]
},
]
}
};
if(event.source.forReal && (event.source.stampName == "#stamp1"))
{
if ("ok" == app.execDialog(DiaBox))
{
this.getField("By").value = ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name);
this.getField("Date").value = util.printd("h:MM tt,dd-mmm-yyyy", new Date());
this.getField("Comment").value = results["Name"];
this.getField("rado1").checkThisBox(0, DiaBox.bChk1);
this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);
this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);
this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);
console.println("Stamp Name: " + event.source.stampName);
var cMsg = DiaBox.byName;
event.value = "Comment # " + cMsg;
event.source.source.info.exhibit = cMsg;
}
}
Copy link to clipboard
Copied
The item ID can only be four letters long. You are using for example "Choice4" - this will not work.
Copy link to clipboard
Copied
I edited it and changed it to "Btn1" and so on. Still not transferring the selection from the dialog box onto the stamp
var DiaBox =
{
result:"cancel",
DoDialog: function()
{return app.execDialog(this);
},
bChk1:false,
bChk2:false,
bChk3:false,
bChk4:false,
stredt1:"",
initialize: function(dialog)
{
var dlgInit =
{
"Btn1": this.bChk1,
"Btn2": this.bChk2,
"Btn3": this.bChk3,
"Btn4": this.bChk4,
"Name": this.stredt1,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var results = dialog.store();
this.bChk1 = results["Btn1"];
this.bChk2 = results["Btn2"];
this.bChk3 = results["Btn3"];
this.bChk4 = results["Btn4"];
this.byName = results["Name"];
},
description:
{
name: "stamp1",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Please select the review category:",
width: 152,
height: 23,
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "radio",
item_id: "Btn1",
group_id: "Group1",
name: "Reviewed",
},
{
type: "radio",
item_id: "Btn2",
group_id: "Group1",
name: "Reviewed with changes noted",
},
{
type: "radio",
item_id: "Btn3",
group_id: "Group1",
name: "Revise and Resubmit",
},
{
type: "radio",
item_id: "Btn4",
group_id: "Group1",
name: "Rejected",
},
{
type: "edit_text",
item_id: "Name",
height: 35,
char_width: 20,
char_height: 10,
alignment: "align_center",
name: "Enter Comments",
}
]
},
{
type: "gap", //Add a small vertical gap between
height: 10 //..radio fields and buttons
},
{
type: "ok_cancel",
},
]
},
]
}
};
if(event.source.forReal && (event.source.stampName == "#stamp1"))
{
if ("ok" == app.execDialog(DiaBox))
{
this.getField("By").value = ((!identity.name || identity.loginName != (event.source.source || this).Collab.user) ? (event.source.source || this).Collab.user : identity.name);
this.getField("Date").value = util.printd("h:MM tt,dd-mmm-yyyy", new Date());
this.getField("Comment").value = this.byName;
this.getField("cbx1").checkThisBox(0, DiaBox.bChk1);
this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);
this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);
this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);
console.println("Stamp Name: " + event.source.stampName);
var cMsg = DiaBox.byName;
event.value = "Name " + cMsg;
event.source.source.info.exhibit = cMsg;
}
}
Copy link to clipboard
Copied
Are you getting any error messages on the JavaScript console?
Copy link to clipboard
Copied
There is only one stamp name , that is one used by JavaScript, and then there is the stamp user label that one sees displayed by the UI.
Dynamic stamp secrets using JavaScript and Acrobat XI by Thom Parker
Copy link to clipboard
Copied
I have an error :
TypeError: this.getField(...) is null
115:App:Calculate
Copy link to clipboard
Copied
Check your line #115, you are trying to reference a field that does not
exist.
Copy link to clipboard
Copied
Okay, I've fixed the error on line #115 but now I have these errors ( see below) . and line 125 is this this.getField("Btn1").checkThisBox(0, DiaBox.bChk1);
Btn 1 thru Btn4 is the item_id of each of my radio button
TypeError: this.getField(...) is null
125:App:Calculate
TypeError: event.source is null
116:Field:Calculate
TypeError: this.getField(...) is null
125:App:Calculate
TypeError: event.source is null
116:Field:Calculate
TypeError: event.source is null
116:Field:Calculate
Copy link to clipboard
Copied
"stamp1" can't be the name of your stamp. You need to find out the internal AP name.
Also, change this line:
if (event.source.forReal && (event.source.stampName == "#stamp1")) {
to:
if (event.source && event.source.forReal && (event.source.stampName == "#stamp1")) {
Copy link to clipboard
Copied
What is an internal AP name mean?
Copy link to clipboard
Copied
It's a property of the stamp. To find it out apply your stamp to a page, select it with the mouse, and then run this code from the JS Console:
this.selectedAnnots[0].AP
This is the value you need to use as the stampName in your code.
Copy link to clipboard
Copied
Take a look at this tutorial, it explains how you would use the AP property: https://acrobatusers.com/tutorials/dynamic_stamp_secrets
Copy link to clipboard
Copied
the name of my stamp is #stamp1 because I named it that way.
Copy link to clipboard
Copied
My problem or error is this statement this.getField("Btn1").checkThisBox(0,DiaBox.bChk1);
it's giving me an error of NULL and I don't understand why
Copy link to clipboard
Copied
That means there's no field with that name in your file.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more