Acrobat Javascript对话框不会返回所有字段值

问题描述

这是我第一次尝试在Acrobat JavaScript中融合一个有点智能的文档。我使用的不是Acrobat,而是一个名为PDFill的免费应用程序,它可以输入JavaScript,但无法运行。我通过在没有JavaScript控制台的Acrobat Reader中打开脚本来运行脚本(但是,如果我还没有找到它,请告诉我)。

目标是创建一个表单,该表单在用户打开文档时弹出,询问其姓名,公司和电子邮件地址,然后通过HTTP调用将其发送到服务器。

>

问题是该表单似乎未返回commit()方法中的所有字段。只有name字段可以正常工作。

这是表单出现时的外观。 name字段已填写,但其余字段未填写。字段的顺序无关紧要,始终相同。

No field content...

这是commit()中对话框的显示。显然,email字段的值仍然会收到,但是该字段的名称会丢失。

Only part of the data...

来源:

var dataDialog = {
    initialize: function (dialog) {
        dialog.load({
            company: 'Whatever Co. Ltd.',name: 'John Doe',email: '[email protected]'
        });
    },commit: function (dialog) {
        var data = dialog.store();

        app.alert(JSON.stringify(data));

        //  Form validation
        if (data.name.length < 3) {
            app.alert('Please enter your name!');
            app.execDialog(dataDialog);
        }

        if (data.company.length < 2) {
            app.alert('Please enter the company name!');
            app.execDialog(dataDialog);
        }

        //  Send to URL
        // this.getURL('http://localhost:5000/pdfReceive/' + encodeURIComponent(data.name) + '/' + encodeURIComponent(data.company) + '/' + encodeURIComponent(data.email));
    },description: {
        name: "DataDialog",elements: [
            {
                type: "view",elements: [
                    { name: "Fill this form,mortal!",type: "static_text",},{ type: "gap" }
                ]
            },{
                type: "view",elements: [
                    { name: "Who owns you:",type: "static_text" },{ item_id: "company",type: "edit_text",char_width: 50 }
                ]
            },elements: [
                    { name: "How they call you:",{ item_id: "name",elements: [
                    { name: "Your email:",{ item_id: "email",char_width: 50 },{ type: "ok",}
                ]
            }

        ]
    }
};

app.execDialog(dataDialog);

更新:有趣的是,如果我将表单字段从emailcompany重命名txt1txt2等。他们工作。尽管这是完成此简单任务的一种可接受的解决方案,但有人可以确认字段名称有限制吗?

解决方法

找到答案了,这很荒谬。表单字段名称不能超过4个字符。超过4个字符的字段名将变成点字符,如屏幕截图所示。如果两个字段的名称超过4个字符,则其中一个将消失。

不能确定是错误,功能还是在星期五。