1 Star 0 Fork 216

一夜花开 / python-learn

forked from mktime / python-learn 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
test_pdf2images.py 605 Bytes
一键复制 编辑 原始数据 按行查看 历史
内部项目 提交于 2021-03-26 16:02 . 增加sorted用法
import fitz
import os
'''
pip install fitz
pip install PyMuPDF
'''
# 调整zoom_x/zoom_y 可以调整图片清晰度
def pdf_image(pdfPath,imgPath,zoom_x,zoom_y,rotation_angle):
pdf = fitz.open(pdfPath)
for pg in range(0, pdf.pageCount):
page = pdf[pg]
trans = fitz.Matrix(zoom_x, zoom_y).preRotate(rotation_angle)
pm = page.getPixmap(matrix=trans, alpha=False)
pm.writePNG(imgPath+str(pdfPath)+"_" + str(pg) + ".png")
pdf.close()
data = [x for x in os.listdir('.') if x.endswith('.PDF')]
for i in data:
print(i)
pdf_image(i, "..\\output\\",1,1,0)
Python
1
https://gitee.com/change_word_by_self/python-learn.git
git@gitee.com:change_word_by_self/python-learn.git
change_word_by_self
python-learn
python-learn
master

搜索帮助