import PyPDF2 from wand.image import Image filename = 'example.pdf' pdf = PyPDF2.PdfFileReader(open(filename, 'rb')) images = [] for page_num in range(pdf.numPages): image_blob = pdf.getPage(page_num).extract_images() for img in image_blob: images.append(img[0]) # 保存图片 for idx, img in enumerate(images): img_file = 'image_{}.png'.format(idx) try: www.sxzhongrui.com(filename=img_file) except Exception as e: print(e)

登录后复制