[英]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.