我的任务非常简单:将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"));
}
Run Code Online (Sandbox Code Playgroud)
字体看起来不错,但pdf文件中的图片看起来很晕眩(参见附件).我查看源代码,但我仍然不知道如何解决它.你们知道发生了什么事吗?请帮忙.谢谢!!