提问人:Kelvin Spicer 提问时间:9/11/2023 最后编辑:Chris BarrKelvin Spicer 更新时间:9/11/2023 访问量:43
一键完成两项任务;附上图像/pdf 和图像/pdf 的缩略图,Adobe Acrobat Forms
Two tasks in one click; Attach image/pdf & thumbnail of image/pdf, Adobe Acrobat Forms
问:
我需要很大的帮助。如果您已经掌握知识或可以为我解决这个问题,我一定会给小费。
在Adobe Acrobat Pro表单中,我正在尝试创建一个按钮,该按钮将允许我的技术人员在要求报销时将燃料和其他购买收据插入表单。该按钮只需要是一个矩形框,单击该框时,将打开他们的桌面(窗口)并让他们选择要添加的文件。
例如:如果他们选择汽油收据 jpeg,它将显示收据的缩略图大小的图片,并将图片附加到表单中。然后,在查看提交的表单时,我可以在附件视图中看到该图片。此外,一个弹出窗口说附件成功也会很好。
实际上,我有一个按钮,其中包含在我创建的练习表单上创建的 JavaScript,但它让我选择了该文件两次。我使用了文档javascript并在按钮属性下运行javascript。显然,我的剧本中某处存在差异。即使它有效,选择两次文件也是一个问题。我更喜欢一键执行这两个命令。
提前感谢您提供的任何帮助。
在按钮上,我选择了运行 javascript;并输入以下内容:
event.target.buttonImportIcon();
if (app.viewerVersion < 11) {
import_pre_11();
} else {
import_11();
}
然后我去了 Javascript 编辑器/文档 Javascript;并import_file并形成我添加以下内容的脚本。
// Initialize attachment number
attachment_num = 1;
// Initial location of file attachment icon
// The x value is incremented below
var oFAP = {x_init: -72, x: -72, y: -72}; // Below lower-left corner of the page
function import_pre_11() {
if (app.viewerType === "Reader") {
app.alert({
cMsg: "You must user Reader version 11 or later to attach files to this form.",
cTitle: "Attach File Error",
nIcon: 3,
nType: 0
});
return;
}
// Prompt user to import a file
app.alert({
cMsg: "Click the OK/Open button after selecting the file from your system that you want to attach.",
cTitle: "Attach File",
nIcon: 3,
nType: 0
});
try {
var rc = this.importDataObject("Attachment" + attachment_image);
if (rc) {
attachment_num += 1;
app.alert({
cMsg: "Attachment successful.\r\rOpen the Attachments panel to access the attached file(s).",
cTitle: "Attachment Successful",
nIcon: 3,
nType: 0
});
} else {
app.alert({
cMsg: "Attachment cancelled.",
cTitle: "Attachment Cancelled",
nIcon: 3,
nType: 0
});
}
} catch (e) {
app.alert({
cMsg: "Could not attach file.",
cTitle: "Could not attach file",
nIcon: 3,
nType: 0
});
}
}
function import_11() {
try {
var annot = addAnnot({
page: event.target.page,
type: "FileAttachment",
author: "Form user",
name: "File Attachment",
point: [oFAP.x, oFAP.y],
contents: "File attachment on: " + util.printd("yyyy/mm/dd HH:MM:ss", new Date()),
attachIcon: "Paperclip"
});
if (annot) app.alert("Attachment successful.",3);
oFAP.x += 18; // Increment the x location for the icon
} catch (e) {
app.alert({
cMsg: "Could not attach file.\r\rPlease report this error.",
cTitle: "File attachment error",
nIcon: 3,
nType: 0
});
}
}
如前所述。该按钮有效,但我必须对文件/图像进行两次拍照。我希望一键完成这两个操作。
答: 暂无答案
评论