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

Dynamic Stamp with 6 Text field entries

flmoeron
Registered: Jun 6 2009
Posts: 8
Answered

I've created a dynamic stamp with 6 text field entries that I've used Thom's PDFDialog program to create the entry for. I can't seem to get the data that is entered to show up on the stamp however.

Right now, I can pull the stamp up, it asks for the data input, and when I click "OK" it puts a blank stamp on the page. I've got the commit function in there, but it's not dropping it in...

The text form fields are "Text1", "Text2" etc...through "Text6".

I've placed the following code under the "Text1" calculation field...

Suggestions?/Reviews?/Glaring Problems?

------------------------------------------------
if(event.source.forReal && (event.source.stampName ==

"#pOICS6hZzCpkYB3pLSQzdD"))

var JSADMDlg1 =
{

result:"cancel",
DoDialog: function(){return app.execDialog(this);},
POSUB:"Text1",
PHASE:"Text2",
CC:"Text3",
H:"Text4",
COMMENTS:"Text5",
AMOUNT:"Text6",
initialize: function(dialog)
{
var dlgInit =
{
"Text1": this.POSUB,
"Text2": this.PHASE,
"Text3": this.CC,
"Text7": this.H,
"Text5": this.COMMENTS,
"Text6": this.AMOUNT,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.POSUB = oRslt["Text1"];
this.PHASE = oRslt["Text2"];
this.CC = oRslt["Text3"];
this.H = oRslt["Text7"];
this.COMMENTS = oRslt["Text5"];
this.AMOUNT = oRslt["Text6"];
},
description:
{
name: "JSADM Dialog",
elements:
[
{
type: "view",
width: 254,
height: 351,
elements:
[
{
type: "view",
width: 236,
height: 354,
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "sta1",
name: "PO/Subcontract #",
},
{
type: "edit_text",
item_id: "Text1",
variable_Name: "POSUB",
width: 131,
height: 23,
char_width: 8,
},
{
type: "static_text",
item_id: "sta2",
name: "Phase",
},
{
type: "edit_text",
item_id: "Text2",
variable_Name: "PHASE",
char_width: 8,
},
{
type: "static_text",
item_id: "sta3",
name: "Cost Code",
},
{
type: "edit_text",
item_id: "Text3",
variable_Name: "CC",
char_width: 8,
},
{
type: "static_text",
item_id: "sta4",
name: "Hold Invoice?",
},
{
type: "edit_text",
item_id: "Text4",
variable_Name: "H",
char_width: 8,
},
{
type: "static_text",
item_id: "sta5",
name: "Comments:",
},
{
type: "edit_text",
item_id: "Text5",
variable_Name: "COMMENTS",
width: 214,
height: 26,
char_width: 35,
},
{
type: "static_text",
item_id: "sta6",
name: "Invoice Amount:",
},
{
type: "edit_text",
item_id: "Text6",
variable_Name: "AMOUNT",
char_width: 8,
},
]
},
{
type: "ok_cancel",
width: 64,
height: 23,
},
]
},
]
}
};

JSADMDlg1.POSUB = "";
JSADMDlg1.PHASE = "";
JSADMDlg1.CC = "";
JSADMDlg1.H = "";
JSADMDlg1.COMMENTS = "";
JSADMDlg1.AMOUNT = "";
if("ok" == JSADMDlg1.DoDialog())
{

console.println("Text1:" + JSADMDlg1.POSUB);
console.println("Text2:" + JSADMDlg1.PHASE);
console.println("Text3:" + JSADMDlg1.CC);
console.println("Text4:" + JSADMDlg1.H);
console.println("Text5:" + JSADMDlg1.COMMENTS);
console.println("Text6:" + JSADMDlg1.AMOUNT);
}

Thanks in advance for the help!

Brian

My Product Information:
Acrobat Pro 8.1.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Everything in this code looks very good except for the last bit. [b]AcroDialogs[/b] writes out sample usage code at the end of the dialog definition, and I see that you have it pasted in here verbatim. This is the bit (Everything inside the "if" statement") that needs to be modified. If you open the console window while you are placing the stamp you'll see that the entered values are being printed to the console.

So, for example, in this line:
      console.println("Text1:" + JSADMDlg1.POSUB);
"JSADMDlg1.POSUB" is the value entered into the dialog.

it should be changed to something like:
this.getField("Text1").value =  JSADMDlg1.POSUB;
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

flmoeron
Registered: Jun 6 2009
Posts: 8
Thanks for the Reply Thom!

I'm getting "Undefined" in each fo the fields when the stamp is placed on the Document...I opened up the console to see what the problem was and I'm getting the following when placing the stamp (typing in a value into each of the dialog fields):

JSADMDlg1 has no properties
140:App:Calculate
JSADMDlg1 has no properties
140:App:Calculate
JSADMDlg1 has no properties
140:App:Calculate

I've changed the language after the If statement to read:

if("ok" == JSADMDlg1.DoDialog())
{

this.getField("Text1").value = JSADMDlg1.POSUB;
this.getField("Text2").value = JSADMDlg1.PHASE;
this.getField("Text3").value = JSADMDlg1.CC;
this.getField("Text4").value = JSADMDlg1.H;
this.getField("Text5").value = JSADMDlg1.COMMENTS;
this.getField("Text6").value = JSADMDlg1.AMOUNT;
}

What am I missing? I ensured the stamp name is correct (ran the code from stamp secrects prior to starting this...)

Thanks in advance!

Brian
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Ahh, I should have seen this earlier. The problem is with the element IDs in the dialog definition. Only 4 letters are allowed in the "item_id" property. Acrobat doesn't recognize element IDs that have more than 4. You must have an old version of AcroDialogs because the new version will not allow more than 4 characters to be entered.

For example, change "Text1" to "txt1".

The ID for the "Hold Invoice" is also out of sync with the Initialize and Commit functions. Change "Text7" to "Txt4"

Also, make sure you have a matching currly brace for this line of code:
if(event.source.forReal && (event.source.stampName == "#pOICS6hZzCpkYB3pLSQzdD")){

There isn't one in the code you've posted above. It should be at the very end of the code.

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

flmoeron
Registered: Jun 6 2009
Posts: 8
Thank you AGAIN for the prompt reply Thom...

I've made the modifications you've suggested, and it's working beautifully!

Thank you for kind peer review and suggestions...

You are and will continue to be a great help to the Acrobat community!

Thanks again Thom!

Brian