abracadabraPDF › Forums › PDF – Général › Tampons – Texte retour « Undefined » › Répondre à : Tampons – Texte retour « Undefined »

bonjour,
J’ai passé pas mal de temps à étudier les tampons et boites de dialogue, donc si je peux me permettre, voici un script un peu « simplifié ».
S’il n’y a rien à initialiser ou rien à vérifier, pas besoin des fonctions « initialize » et « validate » dans le script.
Par contre, si on veut qu’il y ait au moins une case cochée et tous les champs textes remplis, ce serait peut-être bon de les vérifier…
Et si on met les valeurs de la boite de dialogue en variables, autant s’en servir lorsqu’on les rappelle pour remplir les champs !
///////////////////////////////////
// Acrobat JavaScript Dialog
//////////////////////////////////
var oJSDlg={
DoDialog: function(){return app.execDialog(this);},
commit: function (oJSDlg) {
var oRslt=oJSDlg.store();
// Lorsqu'on a plusieurs lignes semblables on peut simplifier
for (var i=1; i<=4; i++) eval("bChk"+i+"=oRslt[\"Chk"+i+"\"];");
for (var i=1; i<=3; i++) eval("text"+i+"=oRslt[\"Txt"+i+"\"];");
},
description: {
name: "Conformité",
elements: [{
type: "view",
width: 362,
height: 200,
elements: [
{
type: "check_box",
item_id: "Chk1",
name: "Vu",
},
{
type: "check_box",
item_id: "Chk2",
name: "Vu avec annotation(s)",
},
{
type: "check_box",
item_id: "Chk3",
name: "Corriger tel qu’annoté",
},
{
type: "check_box",
item_id: "Chk4",
name: "Refusé",
},
{
type: "edit_text",
item_id: "Txt1",
width: 300,
height: 20,
name: "Text Field 1",
},
{
type: "static_text",
name: "Description for Text Field 1",
},
{
type: "edit_text",
item_id: "Txt2",
width: 300,
height: 20,
name: "Text Field 2",
},
{
type: "static_text",
name: "Description for Text Field 2",
},
{
type: "edit_text",
item_id: "Txt3",
width: 300,
height: 20,
name: "Text Field 3",
},
{
type: "static_text",
name: "Description for Text Field 3",
},
{
type: "ok",
},
],
}],
},
};
if (event.source.forReal && event.source.stampName=="#VBC") {
if ("ok"==oJSDlg.DoDialog()) {
// On pourrait également simplifier
this.getField("Chk1").checkThisBox(0,bChk1);
this.getField("Chk2").checkThisBox(0,bChk2);
this.getField("Chk3").checkThisBox(0,bChk3);
this.getField("Chk4").checkThisBox(0,bChk4);
this.getField("Text1").value=text1;
this.getField("Text2").value=text1;
this.getField("Text3").value=text1;
}
}
@+
😎