Copy link to clipboard
Copied
I've been looking into stamps for quite awhile now. I have successfully made a few. At present, I'm playing around with "dynamic stamps" and had some success with creating a few of them as well. I've used the app.response which were easy to create. I was successful with my first attempt.
But, now I want to create the type of stamps that have a pop open interface which asks questions and some have check boxes and drop downs. I haven't found much on the internet as far as tutorials are concerned. I have looked into Thom Parker's book but Dimitri emailed back saying the book only covers very basic types of stamps and would not really be much of a help to me. I found this other website that can provide the types of stamps I talking about but they charge for them and which are secured and do not allow someone to edit.
After spending a tremendous amount time searching the internet I found only one script. So I copy and pasted it into a pdf of my own to play around with it. To my surprise it kinda worked. Somewhat that is. The interface popped open. The fields are fillable. But the rest doesn't work. I tried to create a template and use the name #MyFirstStampB. I only get the Company name to fill in, not the other fields (see the script). So, below is the script. Would someone please take a look at it and tell me how to make it work so I can move on and learn something about creating stamps? I would like to see it work so I can see where I can go with it.
Here's the script: ( a bit lengthy)
var dialog = { companyValue: "", accountValue: "", approvedValue: "", payValue: "",
commit:function (dialog) { // called when OK pressed
var results = dialog.store();
this.companyValue = results["txt1"];
this.accountValue = results["txt2"];
this.approvedValue = results["txt3"];
this.payValue = results["txt4"];
},
description:
{
name: "Account Information", // Dialog box title
elements:
[
{
type: "view",
elements:
[
{
name: "Company name: ",
type: "static_text",
},
{
item_id: "txt1",
type: "edit_text",
multiline: true,
width: 300,
height: 30
},
{
name: "Account Number: ",
type: "static_text",
},
{
item_id: "txt2",
type: "edit_text",
multiline: true,
width: 300,
height: 30
},
{
name: "Approved By: ",
type: "static_text",
},
{
item_id: "txt3",
type: "edit_text",
multiline: true,
width: 300,
height: 30
},
{
name: "Pay Bill: ",
type: "static_text",
},
{
item_id: "txt4",
type: "edit_text",
multiline: true,
width: 300,
height: 30
},
{
type: "ok_cancel",
ok_name: "Ok",
cancel_name: "Cancel"
},
]
},
]
}
};
if(event.source.forReal && (event.source.stampName == "#MyFirstStampB")) { if ("ok" == app.execDialog(dialog)) { var cMsg = dialog.companyValue; event.value = "Company\n" + cMsg; event.source.source.info.company = cMsg;
cMsg = "Account\n" + dialog.accountValue;
this.getField("AccountNumField").value = cMsg;
cMsg = "Approved\n" + dialog.approvedValue;
this.getField("ApproveByField").value = cMsg;
cMsg = "Pay\n" + dialog.payValue;
this.getField("PayBillField").value = cMsg;
} }
I hope someone can help. I really don't want to use this script, just learn from it. Well, thank you all for spending the time reading through this post. If you can help, I would appreciate it. Again, thanks.
Copy link to clipboard
Copied
I would check the JS Console for error messages and also drop this line of code:
event.source.source.info.company = cMsg;
It's really not necessary and can just cause issues.
Copy link to clipboard
Copied
The dialog itself is working fine, by the way.
Copy link to clipboard
Copied
There you are. I just sent you a private email.
Copy link to clipboard
Copied
Creating dialogs in Acrobat's JavaScript is one of the more complex tasks. You should start by reading the relevant section in the API documentation: Acrobat DC SDK Documentation- go through the examples and try to understand what they are doing.
The trickiest part is to get all the {} and [] balanced and matching. This will cause you a lot of lost time (I am speaking of experience here). The best way to speed things up (both in regards to trying to figure out where your JavaScript syntax error message are coming from, but also as far as the learning curve is concerned) is to use the design tool that is offered by pdfscripting.com - you have to be a member to use it, but if you are creating more than just one dialog, it's worth the subscription fee. There are also a few video tutorials on pdfscripting.com about how to create custom dialogs.
Copy link to clipboard
Copied
pdfUser1 wrote
.... I have looked into Thom Parker's book but Dimitri emailed back saying the book only covers very basic types of stamps and would not really be much of a help to me. I found this other website that can provide the types of stamps I talking about but they charge for them and which are secured and do not allow someone to edit.
That is incorrect, Dimitri did not say that. The book covers many advanced dynamic stamp topics, including scripting techniques for handling data in various ways, automating stamps, and other topics. However it only has minor coverage of popup dialogs (it shows the basic technique for creating a dialog and hooking it into the stamp), which are very useful for stamps, but complex enough to be a topic worthy of their own book, i.e. they could no be fully covered in the stamp book.
Fortunately you don't need to know that much about popup dialogs to use them, because we have a drag and drop dialog designer here:
It creates the complex dialog code for you. And then all you need to do is hook it into your stamp.