需要用到 pymupdf 库
安装
pip install PyMuPDF
创建py文件
import fitz pdf_document = fitz.open("12.pdf") #文件位置 for current_page in range(len(pdf_document)): print(current_page) for image in pdf_document.get_page_images(current_page): print(image) xref = image[0] pix = fitz.Pixmap(pdf_document,xref) if pix.n<5: pix.save('imgs/page%s-%s.jpg' %(current_page,xref)) #保存地址 else: pix1 = fitz.Pixmap(fitz.csRGB,pix) pix1.save('imgs/page%s-%s.jpg' %(current_page,xref)) #保存地址 pix1=None pix = None