PDF X-Change Editor : JavaScript : Dynamic Stamp ID : - Stack Overflow

admin2025-04-18  0

I have made an dynamic stamp to stamp my reviewed document. It works fine for me. However, if I share that file to my colleague, it does not works with them. I understand that this is due to the Stamp ID, getting changed for different user.

Can some one advise, how can I change the below JavaScript so that it automatically fetches the Stamp ID.

This problem is specifically in PDF X-Change Editor only.

Below is the JavaScript code I am using.

var dialog = 
{
        nameValue:"",
        dateValue:"",
        cataValue:"",
        catbValue:"",
        catcValue:"",
        catdValue:"",
        ckeckValue:"",
        radioValue:"",

        commit:function (dialog) { // called when OK pressed 
                var results = dialog.store();
                this.nameValue = results["txt1"];
                this.letterValue = results["txt2"];
                this.dateValue = results["txt3"];
        this.checkValue = results["Chk1"];
                this.radioValue = this.getRadioVal(results);
        }, 
        getRadioVal:function(results) 
       {
            for(var i = 1; i <=4; ++i) {
                if(results["chr"+i]) {
                    switch (i) {
                        case 1:
                            var radioVal = "one";
                            break;
                        case 2:
                            var radioVal = "two";
                            break;
                        case 3:
                            var radioVal = "three";
                            break;
                        case 4:
                            var radioVal = "four";
                            break;
                    }
                }
            };
            return radioVal;
        },

        description:
        {      
            type: "view",
            char_height: 15, 
            elements:
            [
            {
                type: "static_text",
                name: "ABC Limited",
                char_width: 30,
                alignment: "align_center",
                font: "dialog",
                bold: true,
            },

            {
                type: "view",
                elements:
                [
                    {
                        type: "view",
                        char_height: 10,
                        elements:
                        [
                            
                            {
                                type: "view",
                                char_width: 8,
                                char_height: 8,
                                align_children: "align_top",
                                elements:
                                [
                                    {
                                        type: "view",
                                        char_width: 8,
                                        char_height: 8,
                                        elements:
                                        [
                                           
            {
                type: "cluster",
                item_id: "cls1",
                name: "Approval / Review Catagory",
                font: "dialog",
                bold: true,
                char_width: 8,
                char_height: 8,
                width: 180,
                height: 215,
                elements:
                    [
                    {
                    type: "view",
                    elements:
                        [
                        {
                            type: "radio",
                            item_id: "chr1",
                            group_id: "Group2",
                            name: "Cat 1 : Approved",
                            },
                            {
                            type: "radio",
                            item_id: "chr2",
                            group_id : "Group2",
                            name: "Cat 2 : Approved with Comments"
                            },
                            {
                            type: "radio",
                            item_id: "chr3",
                            group_id: "Group2",
                            name: "Cat 3 : Approved as Noted"
                            },
                            {
                            type: "radio",
                            item_id: "chr4",
                            group_id: "Group2",
                            name: "Cat 4 : Rejected"
                            }
                         ]
                         }       
                       ]
                       },
                                        ]
                                    },
                                    {
                                        type: "view",
                                        char_width: 8,
                                        char_height: 8,
                                        elements:
                                        [
                                                                     {
                         type: "cluster",
                         item_id: "cls2",
                         name: "Transmittal Details",
                         font: "dialog",
                         bold: true,
                         char_width: 8,
                         char_height: 8,
                        width: 180,
                        height: 215,
                         elements:
                         [
                         {
                         name: "Transmittal #: ",
                         type: "static_text"
                         },
                         {
                         item_id: "txt2",
                         type: "edit_text",
                         width: 150
                         },
                         {
                         name: "Date: (dd.mmm.yyyy) ",
                         type: "static_text"
                         },
                         {
                         item_id: "txt3",
                         type: "edit_text",
                         width: 150
                         }
                       ]
                       },
                                        ]
                                    },
                                ]
                            },
                        ]
                    },

                         {       
                         type: "ok_cancel",
                         ok_name: "Ok",
                         cancel_name: "Cancel"
                         }, 
                ]
            },
        ]
    }
};



if(event.source.forReal && (event.source.stampName == "#m1bkX2Zev6_mnEa3l14wK3"))

{
  if ("ok" == app.execDialog(dialog))
  {
this.getField("cat1").fillColor = color.transparent;
this.getField("cat2").fillColor = color.transparent;
this.getField("cat3").fillColor = color.transparent;
this.getField("cat4").fillColor = color.transparent;
this.getField("cat").fillColor = color.transparent;
this.getField("notstamped").fillColor = color.transparent;
this.getField("cat1").value = " ";
this.getField("cat2").value = " ";
this.getField("cat3").value = " ";
this.getField("cat4").value = " ";
this.getField("cat").value = " ";
this.getField("notstamped").value = " ";
this.getField("name").value = "SSS";
this.getField("project").value = "ABC Project";


      if (dialog.letterValue == "")
          {this.getField("letter").value = "XXXX";}
          else{
    this.getField("letter").value = dialog.letterValue;
          }


      if (dialog.dateValue == "")
          {this.getField("date").value = util.printd("dd.mmmm.yyyy", new Date());}
            else{
                this.getField("date").value = dialog.dateValue;
                }

    if(dialog.radioValue == "one")
    {
        this.getField("cat1").fillColor = color.blue;
        this.getField("cat1").value = "√";
        this.getField("cat").value = "1";
    }
    else if(dialog.radioValue == "two")
    {
        this.getField("cat2").fillColor = color.blue;
        this.getField("cat2").value = "√";
        this.getField("cat").value = "2";  
    }
    else if(dialog.radioValue == "three")
    { 
        this.getField("cat3").fillColor = color.blue;
        this.getField("cat3").value = "√";
        this.getField("cat").value = "3";  
    }
    else if(dialog.radioValue == "four")
    { 
        this.getField("cat4").fillColor = color.blue;
        this.getField("cat4").value = "√";
        this.getField("cat").value = "4";  
    }

    app.execMenuItem("PDFOptimizer");

   
  }
  else{
    this.getField("letter").value = "-x-x-x-";
    this.getField("notstamped").value = "STAMP AGAIN";
    this.getField("date").value = "XX.XXXX.YYYY";
  }
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1744970132a277436.html

最新回复(0)