我在Bluebeam(很棒的PDF编辑器)中从现有的样本图章开始创建自定义图章已经取得了一些成功。我有一个图章,它有一个自定义文本字段,该字段有一个下拉菜单,其中有预先确定的选项可供选择。图章还有其他几个文本字段,其中一些允许用户输入数据,另一些允许用户提取数据-当前日期和用户名。
所有这一切都工作得很好,但我想添加第二个文本字段与预定义的选项,似乎没有办法做到这一点。
这个软件的工作方式是,有一个“计算”javascript,每当邮票第一次放在PDF上时,它就会运行。计算代码创建用户界面,供用户输入日期。计算代码引用“stampcode”javascript。“stampcode”引用邮票本身(也是PDF文件)中的特定元素。
我想我已经得到了正确的stampcode设置。我认为计算代码是什么需要编辑。我得到的感觉这是一个相当简单的过程,我只是一个相当新手编码,真的不知道从哪里开始。我花了大约4个小时试图调整计算代码,并没有运气。任何帮助将不胜感激。(我正在使用visual studio代码进行编辑)。
印章代码:
var builder =
{
// These map to Text Fields in the Stamp
textBoxes :
[
{ field:"Client", description:"Client:", default:function() { return ""; } },
{ field:"Project_Number", description:"Project No.:", default:function() { return ""; } },
{ field:"Expense_Date", description:"Date of Exp.:", default:function() { return ""; } },
{ field:"Markup", description:"Markup %:", default:function() { ""; } },
{ field:"CheckedBy", description:"Checked by:", default:function() { return Collab.user; } },
{ field:"Date", description:"Date:", default:function()
{
var curDate = new Date();
return (curDate.getMonth() + 1) + "/" + curDate.getDate() + "/" + curDate.getFullYear();
}
},
],
// This maps to a Radio Group in the PDF named 'Status'
radioGroup : "Status",
radioButtons :
[
// value maps to the 'Choice' of each radio button in the group, description will show on the dialog
{ value:"Approved", description:"Approved" },
{ value:"Revise", description:"Revise" },
{ value:"Rejected", description:"Rejected" }
],
// This maps to a Popup Group in the PDF named 'Reimburse'
popupGroup: "Reimburse",
listItems :
[
{popupItems :
{
//list of items of Popup menu, positive number indicates default selection
"XXX": -1,
"XXX": -1,
"DC": -1,
"CC": -1
}
}
],
// This maps to a Popup Group in the PDF named 'Service'
popupGroup: "Service",
listItems :
[
{popupItems :
{
//list of items of Popup menu, positive number indicates default selection
"00": -1,
"10": -1,
"20": -1,
"30": -1,
"40": -1,
"50": -1,
"51": -1,
"55": -1,
"60": -1,
"65": -1,
"70": -1,
"80": -1,
"81": -1,
"90": -1,
"91": -1,
"99": -1
}
}
],
// This maps to a Radio Group in the PDF named 'Status'
radioGroup : "Status",
radioButtons :
[
// value maps to the 'Choice' of each radio button in the group, description will show on the dialog
{ value:"Billable", description:"Billable" },
{ value:"Not Billable", description:"Not Billable" }
],
radioErrorMsg : "Please select a status",
}
计算代码:
// WARNING: DO NOT EDIT
// SEE GLOBAL JAVASCRIPT SECTION FOR CUSTOMIZATION
if (event.source.forReal)
{
var stampDialog = CreateDialog(builder);
app.execDialog(stampDialog);
this.getField(builder.radioGroup).value = stampDialog.radioSelection;
this.getField(builder.popupGroup).value = stampDialog.popupSelection;
for (var i = 0; i < builder.textBoxes.length; ++i)
{
var t = builder.textBoxes[i];
this.getField(t.field).value = stampDialog.textBoxResults[i];
}
}
function CreateDialog(dialogBuilder)
{
var sd = new Object();
sd.builder = dialogBuilder;
sd.radioSelection = "";
sd.popupSelection = "";
sd.textBoxResults = new Array();
var popupElements = new Array();
popupElements[0] =
{
type: "popup",
item_id: "popupItems",
field: sd.builder.popupGroup,
width: 250
};
var popupCluster =
{
type: "cluster",
name: builder.popupGroup,
elements: popupElements
};
var stateElements = new Array();
for (var i = 0; i < dialogBuilder.radioButtons.length; ++i)
{
var c = dialogBuilder.radioButtons[i];
stateElements[i] =
{
type: "radio",
name: c.description,
item_id: "rad" + i,
group_id: "grp1"
};
}
var stateCluster =
{
type: "cluster",
name: "Status",
alignment: "align_center",
align_children: "align_distribute",
elements: stateElements
};
var optionsElements = new Array();
for (var i = 0; i < dialogBuilder.textBoxes.length; ++i)
{
var view = new Object();
view.type = "view";
view.align_children = "align_row";
view.elements = new Array();
var t = dialogBuilder.textBoxes[i];
var s = new Object();
s.type = "static_text";
s.item_id = "sta" + i;
s.name = t.description;
s.width = 90;
var e = new Object();
e.type = "edit_text";
e.item_id = "edt" + i;
e.width = 150;
view.elements[0] = s;
view.elements[1] = e;
optionsElements[i] = view;
}
var optionsCluster =
{
type: "cluster",
name: "Options",
elements: optionsElements
};
sd.initialize = function(dialog)
{
var init = new Object();
for (var i = 0; i < this.builder.textBoxes.length; ++i)
{
var t = this.builder.textBoxes[i];
var id = "edt" + i;
init[id] = t.default();
}
dialog.load(init);
dialog.load(this.builder.listItems[0]);
};
sd.commit = function(dialog)
{
var res = dialog.store();
for (var i = 0; i < this.builder.radioButtons.length; ++i)
{
var c = this.builder.radioButtons[i];
var id = "rad" + i;
if (res[id] == true)
{
this.radioSelection = c.value;
break;
}
}
for (var i = 0; i < this.builder.textBoxes.length; ++i)
{
var t = this.builder.textBoxes[i];
var id = "edt" + i;
this.textBoxResults[i] = res[id];
}
for (var i in res["popupItems"])
if (res["popupItems"][i] >0)
{
this.popupSelection = i;
}
};
sd.validate = function(dialog)
{
var res = dialog.store();
for (var i = 0; i < this.builder.radioButtons.length; ++i)
{
var c = this.builder.radioButtons[i];
var id = "rad" + i;
if (res[id] == true)
return true;
}
app.alert(this.builder.radioErrorMsg);
return false;
};
sd.description =
{
name: "Stamp Dialog",
elements:
[
{
type: "view",
align_children: "align_fill",
elements:
[
popupCluster,
stateCluster,
optionsCluster
]
},
{
type: "ok"
}
]
};
return sd;
}
2条答案
按热度按时间yyyllmsg1#
我在理解Bluebeam中的stamps API时也遇到了麻烦。对我来说,一个很大的帮助是偶然接触到Adobe Javascript API reference。这些stamps的大多数API都是Adobe标准的一部分。它不是Bluebeam特有的。
我将您的代码恢复为Bluebeam网站上提供的custom stamp template的参考代码。
计算脚本
印章代码
clj7thdc2#
完全意识到这可能为时已晚,但我修改了Bluebeam原始代码,因为它不完全是我所寻找的,未来的我/任何人与此问题我已经创建了一个模块化的方法:
https://github.com/Jacen-crudo/Bluebeam-Stamp-DiagBox
它还具有安装和修改说明。