简体   繁体   English

Adobe Acrobat Pro XI - 将Javascript添加到PDF

[英]Adobe Acrobat Pro XI - Adding Javascript to a PDF

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. 目的是拥有一个PDF文件,打开时会弹出一条带有“是”和“否”选项的警报消息。 Click Yes, and the alert goes away, leaving the PDF to be read. 单击是,警报消失,将PDF读取。 Click No, and the file closes. 单击否,文件将关闭。

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. 我在网上看过的所有教程都向我展示了代码,但没有在哪里编写代码。

In Adobe Acrobat open Tools pane on the right, select JavaScript section and then Document JavaScripts. 在右侧的Adobe Acrobat打开“工具”窗格中,选择“JavaScript”部分,然后选择“文档JavaScripts”。
Enter a script name and click Add. 输入脚本名称,然后单击“添加”。 In the JavaScript editor remove the generated code and add yours: 在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. 打开文档时,将自动执行此代码(如果未放入函数中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM