python pdf 转图片

import fitz

doc = fitz.open(h_path_pdf) #pdf路径
for pg in range(doc.pageCount):
    page = doc[pg]
    rotate = int(0)
    # 每个尺寸的缩放系数为2,这将为我们生成分辨率提高四倍的图像。
    zoom_x = 2.0
    zoom_y = 2.0
    trans = fitz.Matrix(zoom_x, zoom_y).preRotate(rotate)
    pm = page.getPixmap(matrix=trans, alpha=False)
    pm.writePNG(receipt_pictures+'\\%s.png'% str(pg+1) ) #最终存储路径
print()

你可能感兴趣的:(python pdf 转图片)