1. PDF to Image Converter (pdfbox)
import sys sys.path.append(r"D:\jarlibs\pdfbox-app-2.0.11.jar") from java.awt.image import * from java.io import * from org.apache.pdfbox.pdmodel import * from org.apache.pdfbox.rendering import * from org.apache.pdfbox.tools.imageio import * def PdfToPng(file,folder): pdf = PDDocument.load(File(file)) dir = File(folder) if not dir.exists(): dir.mkdirs() render = PDFRenderer(pdf); for page in range(pdf.getNumberOfPages()): bim = render.renderImageWithDPI(page, 300, ImageType.RGB) ImageIOUtil.writeImage( bim, folder + "/image_%04d.png" % page, 300 ) if __name__ == '__main__': PdfToPng("D:/a.pdf", "D:/a.pdf.out2" )
댓글 없음:
댓글 쓰기