dynamic stamp with checkbox

I am trying to make a submittal stamp with a checkbox dialog. I have cobbled it together from several sources. It works almost... With each time that it is used the checkboxes are duplicated on each other in the source stamp. I do not see in my code where the repeat loop is occuring. Any help would be appreciated.

Code is part of the calculate script on a hidden text field:

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,
bChk6:false,
initialize: function(dialog)
{
var dlgInit =
{
"Chk2": this.bChk2,
"Chk3": this.bChk3,
"Chk4": this.bChk4,
"Chk5": this.bChk5,
"Chk6": this.bChk6,
};
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"];
this.bChk6 = oRslt["Chk6"];
},
description:
{
name: "Approval",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "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: "No Exceptions Taken",
},
{
type: "check_box",
item_id: "Chk3",
name: "Make Corrections Noted",
},
{
type: "check_box",
item_id: "Chk4",
name: "Amend and Re-Submit",
},
{
type: "check_box",
item_id: "Chk5",
name: "Rejected",
},
{
type: "check_box",
item_id: "Chk6",
name: "Not Reviewed",
},
]
},

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

// Example Code








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

var namef = "net";
var typef = "checkbox";
var pagef = 1;
var f = this.addField(namef, typef, pagef, [18, 104, 26, 96]);

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

var namej = "ar";
var typej = "checkbox";
var pagej = 1;
var j = this.addField(namej, typej, pagej, [18, 95, 26, 87]);

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

var namek = "mcn";
var typek = "checkbox";
var pagek = 1;
var k = this.addField(namek, typek, pagek, [18, 86, 26, 78]);

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

var namem = "rej";
var typem = "checkbox";
var pagem = 1;
var m = this.addField(namem, typem, pagem, [18, 77, 26, 69]);

var m = this.getField("rej");
m.strokeColor = color.red;
m.borderStyle = border.s;

var namep = "nr";
var typep = "checkbox";
var pagep = 1;
var p = this.addField(namep, typep, pagep, [18, 68, 26, 60]);

var p = this.getField("nr");
p.strokeColor = color.red;
p.borderStyle = border.s;

if(FormRouting.bChk2){f.checkThisBox(0,true);}
if(FormRouting.bChk3){j.checkThisBox(0,true);}
if(FormRouting.bChk4){k.checkThisBox(0,true);}
if(FormRouting.bChk5){m.checkThisBox(0,true);}
if(FormRouting.bChk6){p.checkThisBox(0,true);}
}
}


Tom Buck


2 Answers

There is no reason to "Add" fields to the stamp. Put the check boxes you want onto the stamp to begin with, and then use the code to set the stamp value. Otherwise the script looks great.

The problem is that Acrobat is saving the stamp file after your code adds the check boxes, So you are constantly adding new checkboxes.

Thom Parker
The source for PDF Scripting Info pdfscripting.com

The Acrobat JavaScript Reference, Use it Early and Often

The most important JavaScript Development tool in Acrobat
The Console Window (Video tutorial)
The Console Window(article)

Having trouble, Why Doesn't my Script Work


Thom Parker   

Ok, I think I know what the issue is. I'm assuming that by "text Fields popup" that you mean an app.response() popup? And that by tab order you mean the order in which these response boxes popup?
The order of stamp script execution is the calculation order of the scripts in the stamp file, not the tab order. I hope this helps.

Also, it is possible (actually preferable) to use the custom popup to collect the text inputs, instead of using individual response boxes. You can easily add these inputs with AcroDialogs. I'm assuming you already have this tool since it was used to create the dialog you are using now.



Thom Parker   


Please specify a reason: