将 PDF 文件保存为与原始 PDF 质量相同的图像
Save PDF file as images with same quality as original PDF
我想将 pdf 文件的每一页保存为单个图像文件:
import fitz
doc = fitz.open('file.pdf')
for i in range(doc.page_count):
page = doc[i]
pix = page.get_pixmap()
pix.save(f'page-{i}.png')
pix.pil_save(f'page-{i}.jpg', optimize = False, dpi = (1500, 1500))
无论我选择哪种分辨率,图像的质量都比原始 pdf 文件差。如何以相同或相似的质量保存它们?
只是一个简单的配置,在get_pixmap()
中添加dpi选项
import fitz
doc = fitz.open('file.pdf')
resolution_parameter = 300
for i in range(doc.page_count):
page = doc[i]
pix = page.get_pixmap(dpi = resolution_parameter)
pix.save(f'page-{i}.png')
pix.pil_save(f'page-{i}.jpg', optimize = False, dpi = (1500, 1500))
我想将 pdf 文件的每一页保存为单个图像文件:
import fitz
doc = fitz.open('file.pdf')
for i in range(doc.page_count):
page = doc[i]
pix = page.get_pixmap()
pix.save(f'page-{i}.png')
pix.pil_save(f'page-{i}.jpg', optimize = False, dpi = (1500, 1500))
无论我选择哪种分辨率,图像的质量都比原始 pdf 文件差。如何以相同或相似的质量保存它们?
只是一个简单的配置,在get_pixmap()
import fitz
doc = fitz.open('file.pdf')
resolution_parameter = 300
for i in range(doc.page_count):
page = doc[i]
pix = page.get_pixmap(dpi = resolution_parameter)
pix.save(f'page-{i}.png')
pix.pil_save(f'page-{i}.jpg', optimize = False, dpi = (1500, 1500))