def pdf2Png: Unit = { val pdfFile = new File("D:/test.pdf") val outFile = new File("D:/test.png") val document = PDDocument.load(pdfFile) val renderer = new PDFRenderer(document) ImageIO.write(renderer.renderImage(0, 3), "png", outFile) document.close() }
比之前用icepdf转换更加简介方便,pdfbox可以到maven官网下载 http://mvnrepository.com/artifact/org.apache.pdfbox/pdfbox/2.0.8