图像转换器
2025/7/21小于 1 分钟pdfbox模块高级功能转换器
提示
JPEG2000格式图像需自行添加依赖
说明
- 支持将多个图像转为 pdf 页面
- 支持自定义页面大小
- 默认页面大小为 A4
- 支持SVG、PNG、JPEG、JPEG2000、BMP、GIF、TIFF等格式
依赖
JPEG2000
<dependency>
<groupId>edu.ucar</groupId>
<artifactId>jj2000</artifactId>
<version>5.2</version>
</dependency>
示例
// 获取图像转换器
ImageConvertor convertor = PdfHandler.getDocumentConvertor().getImageConvertor();
// 转换文档
Document document = convertor.toPdf(new File("E:\\PDF\\pdfbox\\test1.png"), new File("E:\\PDF\\pdfbox\\test2.png"));
// 保存并关闭
document.saveAndClose("E:\\PDF\\pdfbox\\convertor\\image\\test.pdf");