Adobe Acrobat Pro XI - 将 Javascript 添加到 PDF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24307556/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adobe Acrobat Pro XI - Adding Javascript to a PDF
提问by Devan Somaia
This may seem like a really novice question, but I have been tearing my hair out all day on this.
这似乎是一个非常新手的问题,但我一整天都在为此纠结。
I am running the trial version of Adobe Acrobat Professional XI I am looking to add simple JavaScript to a PDF file.
我正在运行 Adobe Acrobat Professional XI 的试用版,我希望将简单的 JavaScript 添加到 PDF 文件中。
The aim is to have a PDF file, that when opened, pops up with an alert message with Yes and No options. Click Yes, and the alert goes away, leaving the PDF to be read. Click No, and the file closes.
目的是拥有一个 PDF 文件,打开该文件时,会弹出带有 Yes 和 No 选项的警告消息。单击是,警报消失,留下 PDF 以供阅读。单击“否”,文件将关闭。
The main trouble I am having is where to write my code. I have used the JavaScript Debugger but it is not very intuitive, and doesn't seem to let me add JavaScript to the file, only run from within the debugger.
我遇到的主要问题是在哪里编写我的代码。我使用了 JavaScript 调试器,但它不是很直观,而且似乎不允许我将 JavaScript 添加到文件中,只能从调试器中运行。
All the tutorials I have looked at online show me the code, but not where to write it.
我在网上看过的所有教程都向我展示了代码,但没有写在哪里。
采纳答案by iPDFdev
In Adobe Acrobat open Tools pane on the right, select JavaScript section and then Document JavaScripts.
Enter a script name and click Add. In the JavaScript editor remove the generated code and add yours:
在 Adobe Acrobat 右侧打开工具窗格中,选择 JavaScript 部分,然后选择文档 JavaScript。
输入脚本名称并单击添加。在 JavaScript 编辑器中删除生成的代码并添加您的代码:
app.alert({cMsg: "JavaScript action: hello", cTitle: "demo title"});
This code (if not placed in a function) will be executed automatically when the document is opened.
此代码(如果未放置在函数中)将在打开文档时自动执行。