• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamic Stamp with dropdown

New Here ,
Jun 02, 2024 Jun 02, 2024

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

TOPICS
JavaScript

Views

553

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2024 Jun 03, 2024

Copy link to clipboard

Copied

Look up popup under property type of the execDialog app method in the Acrobat JavaScript reference guide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2024 Jun 03, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2024 Jun 03, 2024

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

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 04, 2024 Jun 04, 2024

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;
	}
}

@+

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 04, 2024 Jun 04, 2024

Copy link to clipboard

Copied

LATEST

you are the hero of the week!!! thank you!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines