These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Dynamic Stamp and Checkboxes

alexz
Registered: Jan 14 2010
Posts: 2
Answered

Hi all,

I am having trouble getting my dynamic stamp to get data recieved from a JS dialog pop up and replicating it on the stamp itself.

I have used AcroDialogs to create the layout but due to my weak JS knowledge I cannot seem to get the checkbox in the stamp to become checked or unchecked based on the JS dialog.

Are there any example stamps around where a checkbox has been successfully used?

I have been reading through these forums and others all day and I cannot seem to find an answer.

Many thanks,
Alex

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I have not published an example of using a custom dialog with a dynamic stamp. But the issue has of course come up several times. To get this right you have to approach it in stages. To start off I have to assume that both of you have read and successfully excuted on the example for the Dynamic Stamps Tutuorial:
http://www.acrobatusers.com/tutorials/2007/02/dynamic_stamp_secrets

Here are the steps:
1. Create a stamp with a check box that is set at runtime.
2. Use a standard popup box (could be a simple alert box) to set the check value at runtime.
3. Build a custom dialog and use it to set the check box.

I've seen people get hung up on all 3 of these steps. But I'll assume that because you've read and understand the article that your stuck on #3. If you are using AcroDialogs then you have a head start. When AcroDialogs generates the JavaScript code for the custom dialog it includes a usage example at the bottom of the script. Copy the entire AcroDialogs generated script into the calculation event of the field you're using to drive things on your dynamic stamp. This code needs to be inside the "if" that's used to qualify when the stamp code is run. Now all you have to do is to modify the example code for the dialog. Here's an example:

This is the code AcroDialogs writes out for a dialog with a single check box:
// Example CodeJSADMDlg1.bChk1 = false;if("ok" == JSADMDlg1.DoDialog()){ console.println("Chk1:" + JSADMDlg1.bChk1);}

Notice that the check box value is acquired from the dialog with "JSADMDlg1.bChk1"

Here's how I'd modify the code to use with a dynamic stamp that has a check box named "MyCheck":
// Example CodeJSADMDlg1.bChk1 = false;if("ok" == JSADMDlg1.DoDialog()){this.getField("MyCheck").checkThisBox(JSADMDlg1.bChk1,0);}

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kumarp
Registered: Feb 4 2010
Posts: 3
Hi Thomp,
I was able to get date and time dynamically in a stamp. Since i am new to Acrobat Javascript programming please help me develop an interactive stamp.

While creating a stamp with form fields like check box/ text field, the click events on checkbox are caught fine (tested by displaying an alert popup). But when i try to bring the stamp on a Sample Drawing as an stamp the click events for the check box do not work.
Please advise if i am doing something really silly, though you have explained in your previous post clearly the steps to get an interactive stamp.

Thanks in advance for your help
P Kumar
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yep, your doing somthing really silly;^) Once the stamp is placed on a PDF it is no longer interactive. The whole thing is flattened out. At this point it is just a picture.

The previous posts are not about making a stamp interactive, they are about entering data into the stamp immediately before it is placed.

This is a common misperception about stamps, so I'm glad to clear it up.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kumarp
Registered: Feb 4 2010
Posts: 3
Thanks Thomp.
I was able to get the User Input on the stamp for the text fields. For the check boxes you have asked to use acro dialogs. Are acro dialogs compatible with adobe Acrobat version 9.0. ? I cannot see the Acro icon after installing them in the Advanced editing tab.
How should we catch the checkbox input if Acro Dialogs are not yet compatible with version 9.0 of acrobat. Please advise.
Thanks
P Kumar
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
AcroDialogs is a tool for creating the Acrobat Dialog JavaScript. The JavaScript works in all versions of Acrobat and Reader from version 6 and up. AcroDialogs does operate in Acrobat 9, but there are issues with certian operation systems, and system setups.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

kumarp
Registered: Feb 4 2010
Posts: 3
Hi Thomp,
The code sample you provided earlier did not work for me.

// Example Code
JSADMDlg1.bChk1 = false;
if("ok" == JSADMDlg1.DoDialog())
{
this.getField("MyCheck").checkThisBox(JSADMDlg1.bChk1,0);
}

I had to make a slight change to make it working for me:

this.getField("MyCheck").checkThisBox(0, JSADMDlg1.bChk1);


The Acro Dialogs did got installed on Version 9.0. Setup issue was i had previously installed them on version 7.0 and they were not available on version 9.0. So had to uninstall the acro dialogs and then re install for version 9.0.

Acro Dialogs are great..they ROCK and make life easy...
Thanks for your help.
P Kumar
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Excellent!! Getting code to work is all about details. I don't test most of the code I post. I just write it. It's up to you get it working, so good job!

If AcroDialogs has already been installed on a machine then yes, it must be uninstalled first before it can be installed into a new version of Acrobat. I believe this is how all plug-ins work. The license is only for one copy. You're not supposed to copy it around all over the place.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

trep420
Registered: Jul 8 2010
Posts: 1
here is code I used to make a Custom Stamp prompt the used with a dialog box that has three check boxes on it, then checks the associated check-box on the stamp. I looked online forever for this, so I thought i should post this. I would attached the PDF if i could.

it's not the most elegant code, but it works. just make sure you have the correct page # and stamp name. I just put this code in the "calculation" part of a hidden text box. the text box will return the stamp name if visible.

event.value = event.source.stampName;

console.println("Stamp Name: " + event.source.stampName);




var FormRouting =
{

result:"cancel",
DoDialog: function(){return app.execDialog(this);},
bChk2:false,
bChk3:false,
bChk4:false,
bChk5:false,
initialize: function(dialog)
{
var dlgInit =
{
"Chk2": this.bChk2,
"Chk3": this.bChk3,
"Chk4": this.bChk4,
"Chk5": this.bChk5,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.bChk2 = oRslt["Chk2"];
this.bChk3 = oRslt["Chk3"];
this.bChk4 = oRslt["Chk4"];
this.bChk5 = oRslt["Chk5"];
},
description:
{
name: "WSB Approval",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "WSB Approval",
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "view",
char_width: 8,
char_height: 8,
align_children: "align_top",
elements:
[
{
type: "view",
char_width: 8,
char_height: 8,
elements:
[
{
type: "check_box",
item_id: "Chk2",
name: "Reviewed",
},
{
type: "check_box",
item_id: "Chk3",
name: "Reviewed as Noted",
},
{
type: "check_box",
item_id: "Chk4",
name: "Revise and Re-Submit",
},
]
},

]
},
]
},
{
type: "ok_cancel",
},
]
},
]
}
};

// Example Code








if(event.source.forReal && (event.source.stampName == "#dsM-G8WrjleFgcfjcmH6DD"))
{
if("ok" == FormRouting.DoDialog())
{

var namef = "reviewed";
var typef = "checkbox";
var pagef = 1;
var f = this.addField(namef, typef, pagef, [255, 255, 275, 235]);

var f = this.getField("reviewed");
f.strokeColor = color.red;
f.borderStyle = border.s;

var namej = "reviewed as noted";
var typej = "checkbox";
var pagej = 1;
var j = this.addField(namej, typej, pagej, [255, 232.5, 275, 212.5]);

var j = this.getField("reviewed as noted");
j.strokeColor = color.red;
j.borderStyle = border.s;

var name = "revise and resubmit";
var type = "checkbox";
var page = 1;
var k = this.addField(name, type, page, [255, 210, 275, 190]);

var k = this.getField("revise and resubmit");
k.strokeColor = color.red;
k.borderStyle = border.s;

if(FormRouting.bChk2){f.checkThisBox(0,true);}
if(FormRouting.bChk3){j.checkThisBox(0,true);}
if(FormRouting.bChk4){k.checkThisBox(0,true);}
}
}
Hajimoto
Registered: Jul 23 2010
Posts: 4
I realize that there has been a lot of dialog regarding the dynamic stamp. I have no experience with Javascript and have been tweaking, editing and trying to make a dynamic stamp with three input boxes.

1) Date (not todays date but a date) that the user inputs.
2) users Initials that can be int he preferences under name if need be.
3) usrer enters a code code be 3 digits or 4.

Once the variables are done, the user applies the stamp and its is final. I have tried everything. I have had the error where as soon as i mouse over the menu choice the imput boxes open in Acrobat even before I select the stamp.

I have read Thom's dynamic stamp tricks.... I am exhausted and just want a pro to help me with by replying with the script that i can paste in and get my life back.

I am honest with you when I say I have been at this for 6 hours.


Please help me.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Both dialogs and the techniques discussed in dynamic stamp secrets are advanced topics. To perform either of these activities you must have at least a minimal skill level with programming.

Believe me when I say that 6 hours is nothing. A Acrobat JavaScript professional might spend close to that much time creating what you are asking for. It does not sound like you are in a position to create what you need, even with help from this forum. I would stronly suggest that you hire a professional.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Hajimoto
Registered: Jul 23 2010
Posts: 4
Thom - I can appreciate what you are saying and I completely agree that I do not possess the advanced skills necessary to write a complete script.

That being said, I have successfully created a Dynamic stamp that has three input dialog windows and it properly places the information when the stamp is applied. The only issue I am having now is that the dynamic stamp is activating while still in the menu system.

Below is a sample of the script that resides under the calculate tab"

var cAsk = "Enter Control Number";
var cMsg=app.response(cAsk);
event.value=cMsg;

The other two inputs are basically the same.

I just need to fix the activation while mousing over in the stamp menu. Can you assist with that? Is there a perimeter that can be added to each query to stop this auto activate issue?

Thank you in advance for any advise.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Read the Dynamic Stamp Secrets article. The answer is there.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

regularflavor
Registered: Dec 13 2010
Posts: 1
trep420 - It would be SOO awesome if you could send me an example of the pdf you made with the checkboxes in a stamp. I have been trying for a week now to get this to work. email is aaaah_bees(at)hotmail.com
judyhammer
Registered: Jan 17 2011
Posts: 4
Thomp, I am using Acrobat 9. I need to create a custom dynamic stamp where the date and time will automatically update. I have my image with my company's logo and space where this information needs to go. I've looked everywhere to figure out how to do this and can find nothing. Lynda.com doesn't have it. The closest I can get at Adobe.com is for Acrobat 8. Can you help?
Thanks!!

By the way, I'm not a programmer, I'm a designer. Plus I need to teach my finance department how to do this.

judy

Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi judyhammer,

If you look at the custom dynamic stamps that come built-in with Acrobat you'll find one that adds the current date and time- then you just need to copy that feature into your stamp. The Dynamic Stamp Secrets article in the Learning Center here discusses how to access all the stamp files in Acrobat.

Sample code and instructions for creating a wide variety of custom dynamic stamps, as well as a video showing how to use dynamic code from other dynamics stamps in your own stamps can be found at-
pdfscripting.com
As with lynda.com it is a membership site and not a free resource, but thought you might be interested since you said you could not find anything in your initial search.
This page in particular lists the stamp articles and resources-
All About PDF StampsI assume you know this, but since you say you want the date and time automatically updated I'll add that after a stamp is placed you cannot update the date/time (after placement the dynamic fields are unchangeable). But you can have a stamp that will provide the current date and time each time you place it on a new PDF.

Hope this helps,

Dimitri
www.pdfscripting.com
www.windjack.com



gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can look at the tutorials about Dynamic stamps on this site.

Creating a Custom Dynamic Stamp by Lori DeFurio
Dynamic Stamp Secrets by Thom ParkerThe exact location of the application and user stamps can change by major version of Acrobat, so you will need to adjust the folder locations appropriately.

George Kaiser

maxcor
Registered: Jun 17 2011
Posts: 3
I have read countless articles and have tried to follow the steps as carefully as possible. Despite all that, my dynamic stamps aren't working.

It's just a simple stamp with a form field for the current date. The stamp appears in my Stamps drop down list but the JavaScript doesn't seem to work. The JavaScript date remains stuck as the stamp's creation date. I have copied/pasted JavaScript from template stamps which use the current date but still no success. Here is the script:

event.value = (new Date()).toString();
AFDate_FormatEx("mmm dd, yyyy");

I have spent many hours trying to debug this. Can someone please help? I would greatly appreciate it.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Did you bring the Stamp into your custom stamps by the Manage Stamps Dialog?

Did you assign the stamp to the "Dynamic" category?

Did you add the form field after adding the stamp to your custom dynamic stamps?

When you go the location of your stamps, what is the name of the PDF with your stamp?

Have you completely exited Acrobat and your web browser and restarted Acrobat before trying your dynamic stamp?

What is the very exact error you are getting in the Acrobat JavaScript Console?

George Kaiser

maxcor
Registered: Jun 17 2011
Posts: 3
Yes, I did bring the Stamp into custom stamps via the Manage Stamps Dialog.

No, I didn't assign it to the "Dynamic" category. Is that necessary? I had created a new category for our custom stamps.

Perhaps that was my error - I have now added the form field after adding the stamp. It seems to be working now. I will monitor it to ensure the date keeps updating properly.

The name of the file is a cryptic long name with letters and numbers.

Yes, I have completely exited Acrobat (not the web browser). I will try that.

No error was appearing in Acrobat - it's just that the date wasn't the current date when the stamp was inserted.

Thank you for the reply George.