如何将JavaScript代码放入PDF文档?
问题描述:
如何将JavaScript代码插入PDF文件?
How do I insert JavaScript code into a PDF file?
我可以编写JavaScript代码,我只想知道如何将其放入文件中,例如,显示当前日期,使用组合框等。
I can code JavaScript, I just wish to know how to put it into a file to, for example, display the current date, use a combobox, etc.
答
JavaScript通常与PDF文档中的对象相关联。例如,如果您希望用户能够通过单击打印按钮来打印PDF,请按照以下步骤操作:
JavaScript is typically tied to objects in a PDF document. For example, if you want the user to be able to print the PDF by clicking a Print button, follow the steps below:
- 添加表单按钮(在高级编辑下完成)
- 右键单击按钮并转到属性
- 单击操作选项卡
- 在
下选择操作:
选择运行JavaScript
- 在代码窗口中输入
print();
- Add a button to the form (done under advanced editing)
- Right click on the button and go to properties
- Click the actions tab
- Under
Select Action:
chooseRun a JavaScript
- put
print();
in the code window
这是一个链接旧的(Acrobat 7.0.5) Acrobat JavaScript脚本
参考让你开始了。
Here's a link to an old (Acrobat 7.0.5) Acrobat JavaScript Scripting Reference to get you started.