SciTech-EECS-Library:
Python 的 pdf 与 image 双向转换库
安装有关 Python 库
pip3 install img2pdf pdf2image Pillow
pdf 转 image
Approach:
- Import the
pdf2image
module - Store a PDF file with convert_from_path()
- Save image with save()
Below is the Implementation.
# import module
from pdf2image import convert_from_path# Store Pdf with convert_from_path function
images = convert_from_path('example.pdf')# Save pages as images in the pdf
for i in range(len(images)):images[i].save('page'+ str(i) +'.jpg', 'JPEG')