通过 Javascript 显示或隐藏 PDF 中的元素
在 PDF 文件中,通过 Javascript API 与表单字段进行交互非常容易。
是否可以对页面上的任意元素执行此操作(特别是显示/隐藏)?比如说,不仅仅是表单字段,还有文本、图形元素、嵌入图像……是否有 API 可以与这些交互?
如果是,我如何识别一个对象?
In PDF files it is quite easy to interact with form fields via the Javascript API.
Is it possible to do this (specifically showing/hiding) to arbitrary elements on a page? Say, not just form fields, but text, graphical elements, embedded images... Is there an API to interact with those?
If yes, how do I identify an object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这很大程度上取决于文档的“扁平化”程度。您可以轻松访问链接、页面标题、图标等,但据我所知,您处理的不是与 HTML DOM 类似的文档,其中所有内容都可以在 some方式。
创建 PDF 时,即使是使用 Illustrator 等分层应用程序,也会合并(展平)文档的各个部分以保持较小的文件大小。每个新的表示层可能包含对于原始设计者来说可能是不相关和/或不连续的元素。页面右上角的某些内容可能会与左下角看似不相关的内容合并。
这完全取决于文档创建者使用的设置。请记住,无论创建者是谁,甚至可能选择根本不将项目转换为 PDF 格式 - 例如,允许将整个页面作为单个图像文件导入。在元素能够被寻址的情况下,您通常必须循环遍历类似的项目来寻找命名元素(例如页面、标题或图标)。
Much of this depends on how "flattened" the document is. You can easily get access to links, page titles, icons, etc., but so far as I know you are not dealing with a document that parallels the HTML DOM, in which everything is able to be referenced in some way.
When a PDF is created, even from a layered application like Illustrator, parts of the document are merged (flattened) to keep the file size small. Each new presentation layer may contain what, to the original designer, may have been unrelated and/or discontiguous elements. Something up in the top right corner of a page may be merged with something seemingly unrelated in the bottom left.
It all depends on what settings the creator of the document used. Bear in mind that whoever created it may even have chosen not to convert items to PDF format at all — for example, it is allowable to import whole pages as single image files. Where elements are able to be addressed, you often have to loop through like items looking for a named element (like a page, or a title, or an icon).
您不能假设用户正在使用平庸且不安全的 Adobe PDF 插件。
You can't assume that the user is using the mediocre and insecure Adobe PDF plugin.