Help with Acrobat JS dialog box please...
Hi there,
Please can someone point me in the right direction or to some examples that may help.
I'm trying to create a dialog that lists all the fields, on a given page, by field name.
That list is then presented to the user who then chooses/selects items in the field name list.
The script will then iterate through the selected list and then perform some style adjustments.
I've manage to create the dialog, containing a list of field names.
I'm stuck on how to pick up the highlighted items in the list in the dialog.
Please can someone help.
Thanks.
function getPageFields(doc, p) {
var fields = [];
for (var i=0; i<doc.numFields; i++) {
var f = doc.getField(doc.getNthFieldName(i));
if ((typeof f.page=="number" && f.page==p) || (typeof f.page!="number" && f.page.indexOf(p)>-1)) fields.push(f.name);
}
var fieldsNew = "";
for ( var i = 1; i < (fields.length); i++) {
fieldsNew = fieldsNew + fields;
if (i < (fields.length-1)) {
fieldsNew = fieldsNew + "\n";
}
}
return fieldsNew;
}
// Dialog Definition
var oDlg = {
strName: "", initialize: function(dialog) {
dialog.load({"usnm":this.strName});
},
commit: function(dialog) {
var data = dialog.store();
this.strName = data[ "usnm"];
},
description: {
name: "PDF Combiner - Processing Parameters", elements: [ {
type: "view", elements: [
{ name: "Instructions:\n\n1. Select the fields to process by highlighting them.\n2. Click 'OK' to process.", type: "static_text", height:65, },
{ item_id: "usnm", type: "edit_text", width:300, height: 300, multiline: "true", },
{ type: "ok_cancel", },
]
},]
}
};
// Dialog Activation
oDlg.strName = "" + getPageFields(this, 0);
if( "ok" == app.execDialog(oDlg)) {
app.alert("Fields chosen\n" + oDlg.strName);
}
