import os import fitzdef covert2pic(file_path, zoom, png_path):doc = fitz.open(file_path)total = doc.page_countfor pg in range(total):page = doc[pg]zoom = int(zoom) # 值越大,分辨率越高,文件越清晰rotate = int(0)trans = fitz.Matrix(zoom / 100.0, zoom / 100.0).prerotate(rotate)pm = page.get_pixmap(matrix=trans, alpha=False)if not os.path.exists(png_path):os.mkdir(png_path)save = os.path.join(png_path, '%s.png' %(pg+1))pm.save(save)doc.close()if __name__ == "__main__":pdfPath = r'C:\Users\Thinkpad\Desktop\100\3证CE.pdf'imagePath = r'C:\Users\Thinkpad\Desktop\100\imgs'covert2pic(pdfPath, 200, imagePath)