简体   繁体   English

用于自定义图章的PDF Javascript在Adobe Reader DC中不起作用

[英]PDF Javascript for Custom Stamp not working in Adobe Reader DC

Code below is for a custom stamp in Adobe Reader. 以下代码用于Adobe Reader中的自定义图章。 This code is for a row of 3 text fields in the stamp table. 此代码用于邮票表中3个文本字段的行。

What it does: Asks for user input in a javascript window when stamp is placed. 它的作用:放置图章时,在javascript窗口中要求用户输入。 Once submitted, the text fields in the table of the custom stamp are filled with input. 提交后,自定义图章表格中的文本字段将填充输入。

Problem: It works in Adobe Acrobat Pro XI for all 3 fields. 问题:它在Adobe Acrobat Pro XI中的所有3个字段均适用。 But fails to work for anything other than the first field in Adobe Reader DC. 但是,除了Adobe Reader DC中的第一个字段以外,它都无法工作。 Resulting in the other 2 fields being blank. 结果其他两个字段为空白。

The fact the first field works means that my code is fine up to the bottom part (" THIS PART HERE!"). 第一个字段起作用的事实意味着我的代码可以精确到最下面的部分(“ THIS PART HERE!”)。 Any help here in fixing or letting me know another way to define field values with user input would be appreciated :) 在修复或让我知道使用用户输入定义字段值的另一种方法方面的任何帮助将不胜感激:)

From what I heard ( PDF JavaScript does not work in Adobe Reader DC but all other Readers ) the new Adobe Reader DC is quite strict on javascript syntax. 据我所知( PDF JavaScript在Adobe Reader DC中不起作用,但在所有其他Reader中 ),新的Adobe Reader DC对JavaScript语法非常严格。

var dialog = {
        noz8Value: "",
        fa8Value: "",
        fl8Value: "",

        commit:function (dialog) { // called when OK pressed
                var results = dialog.store();
                this.noz8Value = results["txt1"];
                this.fa8Value = results["txt2"];
                this.fl8Value = results["txt3"];
        },     

        description:
        {      
                name: "8 Nozzle Load",    // Dialog box title
                elements:
                [      
                        {      
                                type: "view",
                                elements:
                                [      
                                        {      
                                                name: "1st Nozzle ID: ",
                                                type: "static_text",
                                        },     
                                        {      
                                                item_id: "txt1",
                                                type: "edit_text",
                                                width: 300,
                                                height: 30
                                        }, 
                                        {      
                                                name: "Fa (kN): ",
                                                type: "static_text",
                                        },     
                                        {      
                                                item_id: "txt2",
                                                type: "edit_text",
                                                width: 300,
                                                height: 30
                                        },
                                        {      
                                                name: "Fl (kN): ",
                                                type: "static_text",
                                        },     
                                        {      
                                                item_id: "txt3",
                                                type: "edit_text",
                                                width: 300,
                                                height: 30
                                        },
                                ]      
                        },     
                ]      
        }      
};

// THIS PART HERE (below)
//Line below Runs dialog function (prompt window) if stamp is placed down

if(event.source.forReal && (event.source.stampName == "#nozzle"))
{
  if ("ok" == app.execDialog(dialog))
  {
    var cMsg = dialog.noz8Value;
    event.value = "\n" + cMsg;
    event.source.source.info.noz = cMsg;

    var cMsg2 = dialog.fa8Value;
    this.getField("fa8Field").value = cMsg2;

    var cMsg3 = dialog.fl8Value;
    var test1 = this.getField("fl8Field");
    test1.value= cMsg3

 // Above I tried 3 different ways of linking the user input as the field's `value.`   
  }
}

I fixed it! 我修好了它!

Without event.source.source.info.noz = cMsg; 没有event.source.source.info.no​​z = cMsg; the code works. 该代码有效。 The older versions worked fine and were more lenient. 较旧的版本运行良好,并且比较宽松。 DC is strict. DC很严格。

if(event.source.forReal && (event.source.stampName == "#nozzle"))
{
  if ("ok" == app.execDialog(dialog))
  {
    var cMsg = dialog.noz8Value;
    event.value = "\n" + cMsg;

    var cMsg2 = dialog.fa8Value;
    this.getField("fa8Field").value = cMsg2;

    var cMsg3 = dialog.fl8Value;
    var test1 = this.getField("fl8Field");
    test1.value= cMsg3

  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM