繁体   English   中英

在标记自定义动态图章之后,允许编辑表单字段

[英]Allow editing of form field AFTER a custom dynamic stamp is stamped

我有一个工作自定义动态图章,其中有多个输入字段提示用户。 我现在想尝试做的是在实际渲染后以某种方式将表单文本字段添加到图章上。 例如,如果某人最初在分类帐代码以外的所有内容上加盖戳记(因为他们当时不知道),然后将PDF发送给不知道分类帐代码的人,那么我想拥有这些分类帐的能力可以添加的代码,就像它们是可编辑的表单字段一样,不必使用其他标记。

所以说真的,在邮票被“盖章”之后,我真的不再希望它成为邮票了……我希望它现在成为一种形式(我认为...)

这是邮票的工作代码(减去“批准”字段)

    var dialog = {
    VendorNum: "",
    Date: "",
    ProjNumRow1: "",
    ProjNumRow2: "",
    ProjNumRow3: "",
    ProjNumRow4: "",
    GLCodeRow1: "",
    GLCodeRow2: "",
    GLCodeRow3: "",
    GLCodeRow4: "",
    AmountRow1: "",
    AmountRow2: "",
    AmountRow3: "",
    AmountRow4: "",
    Approval: "",

    commit:function (dialog) { // called when OK pressed 
        var results = dialog.store();
        this.VendorNum = results["txt1"];
        this.Date = results["txt2"];
        this.ProjNumRow1 = results["txt3"];
        this.ProjNumRow2 = results["txt4"];
        this.ProjNumRow3 = results["txt5"];
        this.ProjNumRow4 = results["txt6"];
        this.GLCodeRow1 = results["txt7"];
        this.GLCodeRow2 = results["txt8"];
        this.GLCodeRow3 = results["txt9"];
        this.GLCodeRow4 = results["txtA"];
        this.AmountRow1 = results["txtB"];
        this.AmountRow2 = results["txtC"];
        this.AmountRow3 = results["txtD"];
        this.AmountRow4 = results["txtE"];
        this.Approval = results["Approval"];
    },      

    description:
    {       
        name: "Accounts Payable",    // Dialog box title
        width: 400,
        height: 400,
        elements:
        [
            {
                type: "view",
                align_children: "align_left",
                elements:
                [
                    {
                        name: "TopGapPlaceholder",
                        type: "gap",
                        height: 20,
                    },
                ]
            },
            {
                type: "view",
                alignment: "align_center",
                elements:
                [
                    {       
                        name: "ACCOUNTS PAYABLE",
                        type: "static_text",
                        alignment: "align_center",
                        width: 120,
                    },                                
                ]
            },
            {
                type: "view",
                align_children: "align_left",
                elements:
                [
                    {
                        name: "TopGapPlaceholder",
                        type: "gap",
                        height: 20,
                    },
                ]
            },
            {
                type: "cluster",
                elements:
                [
                    {
                        type: "view",
                        width: 70,
                        elements:
                        [
                            {
                                type: "view",
                                align_children: "align_row",
                                elements:
                                [
                                    {       
                                        name: "Vendor #: ",
                                        type: "static_text",
                                        alignment: "align_right",
                                        width: 80,
                                    },      
                                    {       
                                        item_id: "txt1", 
                                        type: "edit_text",

                                        multiline: false,
                                        width: 100,
                                        height: 20
                                    },                                 
                                ]                            
                            },
                            {
                                type: "view",
                                align_children: "align_row",
                                elements:
                                [   
                                    {       
                                        name: "Date: ",
                                        type: "static_text",
                                        alignment: "align_right",
                                        width: 80,
                                    },      
                                    {       
                                        item_id: "txt2", 
                                        type: "edit_text",
                                        multiline: false,
                                        width: 100,
                                        height: 20
                                    },
                                ]  
                            }
                        ]
                    }
                ]
            },
            {
                type: "view",
                align_children: "align_left",
                elements:
                [
                    {
                        name: "AboveProjectsGapPlaceholder",
                        type: "gap",
                        height: 30,
                    },
                ]
            },
            {
                type: "view",
                align_children: "align_row",                
                elements:
                [   
                    {
                        type: "view",
                        elements:
                        [
                            {
                                type: "view",
                                align_children: "align_left",
                                elements:
                                [
                                    {
                                        name: "RowGapPlaceholder",
                                        type: "gap",
                                        height: 20,
                                    },
                                    {       
                                        name: "Row 1: ",
                                        type: "static_text",
                                        height: 20,
                                    },
                                    {       
                                        name: "Row 2: ",
                                        type: "static_text",
                                        height: 20,
                                    }, 
                                    {       
                                        name: "Row 3: ",
                                        type: "static_text",
                                        height: 20,
                                    }, 
                                    {       
                                        name: "Row 4: ",
                                        type: "static_text",
                                        height: 20,
                                    },                                
                                ]                            
                            },
                        ]
                    },                 
                    {                      
                        type: "cluster",                        
                        elements:
                        [
                            {
                                type: "view",
                                align_children: "align_center",
                                elements:
                                [
                                    {       
                                        name: "Project #",
                                        type: "static_text",
                                    },
                                ]
                            },
                            {
                                type: "view",
                                align_children: "align_left",
                                elements:
                                [                    
                                    // PROJECT NUMBERS COLUMN
                                    {       
                                            item_id: "txt3", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },     
                                    {       
                                            item_id: "txt4", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },      
                                    {       
                                            item_id: "txt5", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },
                                    {       
                                            item_id: "txt6", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },
                                ]
                            }
                        ]
                    },
                    {
                        type: "cluster",                        
                        elements:
                        [
                            {
                                type: "view",
                                align_children: "align_center",
                                elements:
                                [
                                    {       
                                        name: "General Ledger Code",
                                        type: "static_text",
                                    },
                                ]
                            },
                            {
                                type: "view",
                                align_children: "align_left",
                                elements:
                                [                    
                                    //  GL CODES COLUMN                                        
                                    {       
                                            item_id: "txt7", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },     
                                    {       
                                            item_id: "txt8", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },      
                                    {       
                                            item_id: "txt9", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },
                                    {       
                                            item_id: "txtA", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },
                                ]
                            }
                        ]
                    },
                    {
                        type: "cluster",                        
                        elements:
                        [
                            {
                                type: "view",
                                align_children: "align_center",
                                elements:
                                [
                                    {       
                                        name: "Amount",
                                        type: "static_text",
                                    },
                                ]
                            },
                            {
                                type: "view",
                                align_children: "align_left",
                                elements:
                                [                    
                                    // AMOUNT COLUMN
                                    {       
                                            item_id: "txtB", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },     
                                    {       
                                            item_id: "txtC", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },      
                                    {       
                                            item_id: "txtD", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },
                                    {       
                                            item_id: "txtE", 
                                            type: "edit_text",
                                            //alignment: "align_row",
                                            multiline: false,
                                            width: 100,
                                            height: 20
                                    },
                                ]
                            }
                        ]
                    },
                ]
            },
            {
                type: "view",
                align_children: "align_left",
                elements:
                [
                    {
                        name: "ButtonGapPlaceholder",
                        type: "gap",
                        height: 50,
                    },
                ]
            },
            {
                type: "cluster",
                align_children: "align_right",
                elements:
                [
                    {
                        type: "view",
                        align_children: "align_row",
                        elements:
                        [
                            // BUTTON GROUP
                            {       
                                    type: "ok_cancel",
                                    ok_name: "Ok",
                                    cancel_name: "Cancel"
                            },      
                        ]
                    }
                ]
            }
        ]          
    }       
}; 

if(event.source && event.source.forReal && (event.source.stampName == "#8ykdtJ56pcQrQ7Sxn1-99A"))
{
  if ("ok" == app.execDialog(dialog))
  {
    console.println(dialog.VendorNum);
    console.println(dialog.Date);
    console.println(dialog.ProjNumRow1);
    console.println(dialog.ProjNumRow2);
    console.println(dialog.ProjNumRow3);
    console.println(dialog.ProjNumRow4);
    console.println(dialog.GLCodeRow1);
    console.println(dialog.GLCodeRow2);
    console.println(dialog.GLCodeRow3);
    console.println(dialog.GLCodeRow4);
    console.println(dialog.AmountRow1);
    console.println(dialog.AmountRow2);
    console.println(dialog.AmountRow3);
    console.println(dialog.AmountRow4);
    if (!dialog.VendorNum) {
        this.getField("VendorNum").value = "";
    } else {
        this.getField("VendorNum").value = dialog.VendorNum;
    }
    if (!dialog.Date) {
        this.getField("Date").value = "";
    } else {
        this.getField("Date").value = dialog.Date;
    }
    if (!dialog.ProjNumRow1) {
        this.getField("ProjNumRow1").value = "";
    } else {
        this.getField("ProjNumRow1").value = dialog.ProjNumRow1;
    }
    if (!dialog.ProjNumRow2) {
        this.getField("ProjNumRow2").value = "";
    } else {
        this.getField("ProjNumRow2").value = dialog.ProjNumRow2;
    }
    if (!dialog.ProjNumRow3) {
        this.getField("ProjNumRow3").value = "";
    } else {
        this.getField("ProjNumRow3").value = dialog.ProjNumRow3;
    }
    if (!dialog.ProjNumRow4) {
        this.getField("ProjNumRow4").value = "";
    } else {
        this.getField("ProjNumRow4").value = dialog.ProjNumRow4;
    }
    if (!dialog.GLCodeRow1) {
        this.getField("GLCodeRow1").value = "";
    } else {
        this.getField("GLCodeRow1").value = dialog.GLCodeRow1;
    }
    if (!dialog.GLCodeRow2) {
        this.getField("GLCodeRow2").value = "";
    } else {
        this.getField("GLCodeRow2").value = dialog.GLCodeRow2;
    }
    if (!dialog.GLCodeRow3) {
        this.getField("GLCodeRow3").value = "";
    } else {
        this.getField("GLCodeRow3").value = dialog.GLCodeRow3;
    }
    if (!dialog.GLCodeRow4) {
        this.getField("GLCodeRow4").value = "";
    } else {
        this.getField("GLCodeRow4").value = dialog.GLCodeRow4;
    }
    if (!dialog.AmountRow1) {
        this.getField("AmountRow1").value = "";
    } else {
        this.getField("AmountRow1").value = dialog.AmountRow1;
    }
    if (!dialog.AmountRow2) {
        this.getField("AmountRow2").value = "";
    } else {
        this.getField("AmountRow2").value = dialog.AmountRow2;
    }
    if (!dialog.AmountRow3) {
        this.getField("AmountRow3").value = "";
    } else {
        this.getField("AmountRow3").value = dialog.AmountRow3;
    }
    if (!dialog.AmountRow4) {
        this.getField("AmountRow4").value = "";
    } else {
        this.getField("AmountRow4").value = dialog.AmountRow4;
    }
    if (!dialog.Approval) {
        this.getField("Approval").value = "";
    } else {
        this.getField("Approval").value = dialog.Approval;
    }    
  }
}

盖章后,便不能再对其进行修改了(可以在页面上四处移动,仅此而已)。

因此,如果您“想将邮票变成表格”,则必须立即从表格开始。 换句话说,为什么不只放置用户可以在文档上填写的表单字段?

您将使用addField()方法添加字段。

如果需要在Reader中支持您的文档,则可以坚持使用Reader XI或更高版本,或者必须添加扩展权限。

实际上,您可以获取动态图章以进行重新渲染。 您需要做的就是使用JavaScript获取与所讨论的图章相对应的注释对象,获取其属性对象,删除APCosObj属性,然后将属性设置为修改后的属性对象。 只要自定义标记仍安装在Acrobat中,该对话框就会弹出并允许用户输入数据。 不幸的是,图章上的现有数据无法直接访问,因此您需要提供一种存储它的机制。 所有注释在创建时都会具有唯一的“名称”属性,因此您可以使用该名称将存储的数据连接到注释。

假设注释是第一页上的第一个注释,则代码可能看起来像这样...

annot = this.getAnnots()[0];
props = annot.getProps();
delete props.APCosObj;
annot.setProps(props);

Acrobat(或Reader)将检测到图章的外观不再存在,因此它将实质上重新标记图章并重新运行代码。

暂无
暂无

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

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