我正在使用Adobe Acrobat Pro DC中的动作向导工具。我想使用"执行Javascript"将水印应用于PDF页面的中心以及侧面和顶部的人名。我成功地完成了这个,这是代码。
var cMyText = "This PDF has been created for exclusive use for Max Power.";
this.addWatermarkFromText({
cText: cMyText,
nFontSize:9,
nHorizAlign:app.constants.align.center,
nVertAlign:app.constants.align.top,
nVertValue:-10,
nOpacity: 0.8,
});
this.addWatermarkFromText({
cText: cMyText,
nFontSize: 9,
nRotation: 90,
nHorizAlign: app.constants.align.left,
nHorizValue: 10,
nVertAlign: app.constants.align.center,
nOpacity: 0.8,
});
this.addWatermarkFromText({
cText: cMyText,
nFontSize:9,
nRotation:-90,
nHorizAlign:app.constants.align.right,
nHorizValue:-10,
nVertAlign:app.constants.align.center,
nOpacity: 0.8,
});
this.addWatermarkFromText({
cText: "DRAFT COPY",
nTextAlign:app.constants.align.center,
cFont: "Helvetica-Bold",
nFontSize:80,
aColor: ["RGB", 0, 0, 1],
nRotation:45,
nOpacity: 0.2,
});
现在,这是我的问题。这条线...
"此PDF创建专供Max Power使用。";
每次运行动作时都会改变。我不想冒险让用户通过直接在代码中编辑来搞乱JavaScript。我想要一个输入框,提示用户在执行操作之前编辑此行。这可能吗?请帮忙!感谢。
答案 0 :(得分:0)
在reference中查看app.reponse()
。
这些方面的东西应该可以解决问题:
var name = app.alert("Please enter name below:");
if (name != null) {
var cMyText = "This PDF has been created for exclusive use for " + user + ".";
...
或者,您可以在每台用户的计算机上放置一个文件夹级Javascript文件,并使用getUser()
函数返回其名称。根据网络环境的不同,这可能是也可能不是一种选择,但它可以使文档级脚本能够确定用户是谁。
答案 1 :(得分:0)
谢谢!下面的代码就行了!
var dialogTitle = "Please Complete";
var string1 = "This PDF has been created for exclusive use for";
var defaultAnswer = "";
var string2 = app.response("Add PDF recipients NAME or COMPANY",
dialogTitle, defaultAnswer);
var string3 = app.response("Add PDF recipients ADDRESS",
dialogTitle, defaultAnswer);
var cMyText = string1 +"\n"+ string2 +" "+ string3;
var string4 = string2 +"\n"+ string3;
this.addWatermarkFromText({
cText: cMyText,
nFontSize:9,
nHorizAlign:app.constants.align.center,
nVertAlign:app.constants.align.top,
nVertValue:-10,
nOpacity: 0.8,
});
this.addWatermarkFromText({
cText: cMyText,
nFontSize:9,
nRotation:90,
nHorizAlign:app.constants.align.left,
nHorizValue:10,
nVertAlign:app.constants.align.center,
nOpacity: 0.8,
});
this.addWatermarkFromText({
cText: cMyText,
nFontSize:9,
nRotation:-90,
nHorizAlign:app.constants.align.right,
nHorizValue:-10,
nVertAlign:app.constants.align.center,
nOpacity: 0.8,
});
this.addWatermarkFromText({
cText: string4,
nTextAlign:app.constants.align.center,
cFont: "Helvetica-Bold",
nFontSize:36,
aColor: ["RGB", 0, 0, 1],
nRotation:45,
nOpacity: 0.2,
bOnTop:false,
});