我的任务非常简单:将PDF文件的每一页转换为图像。我尝试使用开源版本的icepdf生成图像,但它们不能生成正确字体的图像。因此,我开始使用PDFBox代替。代码如下:
PDDocument document = PDDocument.load(new File("testing.pdf"));
List<PDPage> pages = document.getDocumentCatalog().getAllPages();
for (int i = 0; i < pages.size(); i++) {
PDPage singlePage = pages.get(i);
BufferedImage buffImage = convertToImage(singlePage, 8, 12);
ImageIO.write(buffImage, "png", new File(PdfUtil.DATA_OUTPUT_DIR+(count++)+".png"));
}
字体看起来不错,但pdf文件中的图片看起来有些模糊(见附件)。我查看了源代码,但仍然不知道如何修复它。你们有什么想法吗?请帮忙,谢谢!
convertToImage
方法是什么样子的?为了完整起见,你能否把它发布出来呢?这将对我非常有帮助... - Atmocreations