javascript - 将页面级 JavaScript 批量添加到多个 PDF

标签 javascript pdf acrobat

我想添加将在单页 PDF 的页面打开时执行的 JavaScript 代码。将会有多个文件需要执行此操作,我想知道是否有任何方法可以批量处理此操作,而不是手动编辑每个 PDF。

我在网络和库上找到了一些资源,它们允许您以编程方式添加文档级 javascript(例如 http://blog.rsmoorthy.net/2012/01/add-javascript-to-existing-pdf-files.html )

但是我还没有找到任何以编程方式添加页面打开 javascript 的内容。任何有关此问题的指示将不胜感激!

最佳答案

您可以尝试在您的页面中添加一个额外的操作字典,来自 adobe 规范中有关其他操作的信息:

I.2.8 Additional-actions dictionaries (see Section 8.5.2, “Trigger Events”) can be the value of the AA entry of a catalog, page, annotation or field dictionary.

TABLE 8.45 Entries in a page object’s additional-actions dictionary
...
Key: PO
Type: dictionary
Value: (Optional; PDF 1.5) An action to be performed when the page containing the annotation is opened (for example, when the user navigates to it from the next or previous page or by means of a link annotation or outline item). The action is executed after the O action in the page’s additional-actions dictionary (see Table 8.45) and the OpenAction entry in the document catalog (see Table 3.25), if such actions are present.
...

您可以在其中添加 Javascript 操作以及需要执行的代码。

关于javascript - 将页面级 JavaScript 批量添加到多个 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9277222/

相关文章:

javascript - 如何使用 match 从字符串中返回字符?

pdf - PDFTK旋转页面问题

javascript - 如何创建一个后退按钮,该按钮将落在单击以查看图像的特定文本/链接处

javascript - 将 `Intl.NumberFormat` 与 `maximumFractionDigits` 和 `maximumSignificantDigits` 一起使用

javascript - 如何编写服务层规范?

Java JTable 导出为 PDF

java - 如何在android中为pdf查看器制作注释,如突出显示、删除线、下划线、绘制、添加文本等?

linux - 优化 Ghostscript 的方法?

excel - IsNumeric 函数对于空单元格返回 true

javascript - 允许在加盖自定义动态图章后编辑表单字段