如何获取 PDF 文档的页数(无论版本如何)?一些脚本语言
如何获取 PDF 文档的页数?该文档也可以包含图像和不同字体大小的文本。它应该适用于不同的 PDF 文档版本。
答案可以是任何脚本语言,稍后我会将它们移植到 Ruby。
How I can get the number of pages in a PDF document ? The document can have images too, and text in different font size. It should work with different PDF document versions.
The answer can be in any scripting language, I will port them later to Ruby.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 pyPdf:
我认为 Ruby 一定有一个具有类似功能的类似库。
Using pyPdf:
I think there must be a similar library with similar functionality for Ruby.
我能想到一个可能有效的创可贴解决方案。我假设您正在开发一个需要此信息的 Web 应用程序/网页。在这种情况下,让浏览器的 adobe reader 插件加载 pdf 文档。然后,使用该插件将一些“Javascript for pdf”附加/执行到加载的文档,这将返回页数。该函数调用的 DOM 可以在这里找到:
http:// /www.adobe.com/devnet/acrobat/pdfs/js%5Fapi%5Freference.pdf
此外,您还必须收集此信息并将其取回。您可能还会发现本指南很有帮助:
http://www.adobe.com/ devnet/acrobat/pdfs/Acro6JSGuide.pdf
I can think of a band-aid solution which might just work. I am going to assume that you are developing a web application/web page which needs this information. In that case, let the adobe reader plugin for the browser load the pdf document. Then, use the plugin to attach/execute some 'Javascript for pdf' to the loaded document which will return the number of pages. The DOM for that function call can be found here:
http://www.adobe.com/devnet/acrobat/pdfs/js%5Fapi%5Freference.pdf
Further, you must also collect this information and get it back. You may also find this guide helpful:
http://www.adobe.com/devnet/acrobat/pdfs/Acro6JSGuide.pdf