Copy link to clipboard
Copied
Hi mates
I am searching for a simple javascript, which is asks for user input when adding a new stamp. the userinput should be a dropdown field with 5 selectable values.
somebody already did this?
thx
Copy link to clipboard
Copied
Look up popup under property type of the execDialog app method in the Acrobat JavaScript reference guide.
Copy link to clipboard
Copied
Adding a drop-down to the stamp itself is not necessary, since the user can't interact with it anyway. Add a simple text field, but use a drop-down element in the dialog that is used to prompt the user to enter their input when the stamp is applied. Then copy their input into the various fields in the stamp.
Copy link to clipboard
Copied
I have created many dynamic stamps that use dropdowns as input. However, it is not simple. You need to use a custom dialog. Read these articles.
https://acrobatusers.com/tutorials/dynamic_stamp_secrets/
https://www.pdfscripting.com/public/ACRODIALOGS-OVERVIEW.cfm
Copy link to clipboard
Copied
Hi,
Here is an example for a stamp with a dropdown and a quick script:
var theItems=["item #1","item #2","item #3","item #4","item #5"];
var theField="- Select an Item -";
var theList="var theList \= \{\""+theField+"\": "+(theItems.length+1)+",";
for (var i=0; i<theItems.length; i++) {
var itemName=theItems[i];
theList+="\""+itemName+"\": "+(-1*(i+1)).toString()+",";
}
var theList=theList.substring(0,theList.length-1);
theList+="\}";
eval(theList);
var dialogBox={
initialize: function(dialogBox) {
this.loadDefaults(dialogBox);
},
loadDefaults: function(dialogBox) {
dialogBox.load({
LCha: theList,
})
},
validate: function(dialogBox) {
var oRslt=dialogBox.store();
var elements=dialogBox.store()["LCha"];
var testOK=true;
for (var i in elements) {
if (elements[i]>0) {
listValue=theList[i];
listName=i;
}
}
if (listValue>0) var testOK=false;
if (!testOK) app.alert("Please select an item",3);
return testOK;
},
description: {
name: "Stamp with Dropdown",
elements: [
{
type: "view",
elements: [
{
type: "view",
alignment: "align_fill",
elements: [
{
type: "static_text",
name: "Items",
font: "dialog",
bold: true,
},
{
type: "popup",
item_id: "LCha",
width: 150,
alignment: "align_fill",
},
]
},
{
type: "gap",
height: 5
},
{
type: "ok_cancel",
},
]
},
]
}
};
if (event.source.forReal && event.source.stampName=="#bebarth") {
if("ok"==app.execDialog(dialogBox)){
event.value=listName;
}
}
@+
Copy link to clipboard
Copied
you are the hero of the week!!! thank you!!!