用 Java 创建 PDF 的缩略图
我正在寻找一个 Java 库,它可以获取 PDF 并从第一页创建缩略图 (PNG)。
我已经看过 JPedal,但其疯狂的许可费完全令人望而却步。我目前正在使用 iText 来操作 PDF 文件,但我相信它不会生成缩略图。我可以在命令行上使用 Ghostscript 之类的东西,但我希望如果可能的话,让我的项目全部使用 Java。
I'm looking for a Java library that will can take a PDF and create a thumbnail image (PNG) from the first page.
I've already looked at JPedal, but its insane licensing fee is completely prohibitive. I am using iText to manipulate PDF files at the moment, but I believe it doesn't do thumbnail generation. I can use something like Ghostscript on the command line, but I'm hoping to keep my project all-Java if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
PDF Renderer 是一个 LGPL 许可的纯 java 库,它使这变得简单(取自他们的示例页面) ):
PDF Renderer is a LGPL licensed pure-java library that makes this as simple as (taken from their example page):
只要您只使用 PDF 渲染器使用的 PDF 文件的子集,PDF 渲染器就可以。使用 JPod 和 JPedal,您是在为一个活跃且已开发的库而不是一个死项目付费。
PDF Renderer is fine so long as you only use the subset of PDF files they use. With JPod and JPedal you are paying for an active and developed library not a dead project.
在适配器中创建多个 PDF 文件的缩略图,就像使用 Picasso 或 Glide 加载图像一样
您需要集成 picasso 库
之后
您需要创建 PdfRequestHandler 类: -
之后在适配器中创建实例
在适配器的构造函数中初始化实例
然后从适配器的bindViewHolder方法中的路径加载文件
create Multiple PDF file's thumbnails in adapter as like images loading using Picasso or Glide
You need to integrate picasso library
After that
You need to create PdfRequestHandler class :-
After That create instance in adapter
Initilize the instance in constructor of adapter
Then load file from path in bindViewHolder method of adapter
Qoppa Software 有一个 java SDK,可以将 PDF 转换为图像。
https://www.qoppa.com/pdfimages/
Qoppa Software has a java SDK that can convert PDFs to images.
https://www.qoppa.com/pdfimages/
Thumbnails4j (我是维护者,但它属于 Elastic) 是一个 Apache 2 许可的库,用于创建缩略图,并支持 PDF 输入。
Thumbnails4j (I'm a maintainer, but it's owned by Elastic) is an Apache 2 licensed library for creating thumbnails, and supports PDF inputs.