我想转换PDF文件到图像文件(.jpg,或.png ...)。我已经找到了这个解决方案,但我总是得到一个错误:
from pdf2image import convert_from_path
pages = convert_from_path('sample.pdf', 500) # I have tried with full path, and with different num of pages
我得到的错误是:
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
我该如何解决这个问题呢?
如果有任何其他方法转换为.jpg的pdf请让我知道。
发布于 2021-09-07 05:08:57
从以下链接下载Poppler方法
ubuntu的
sudo apt-get install poppler-utils
sudo代码poppler_path
变量(仅适用于windows,不需要linux)从pdf2image导入convert_from_path,convert_from_bytes导入平台if platform.system() == "Windows":pages = convert_from_path(r"C:\ABC\xyz.pdf",500,poppler_path= r‘C:\ABC\poppler 0.68.0\convert_from_bytes’) elif if platform.system() == "Linux":pages = convert_from_path(r"C:\ABC\xyz.pdf",500)对于页面中的页面: page.save(r"C:\ABC\xyz.pdf".lower().replace(".pdf",".jpg"),'JPEG')
https://stackoverflow.com/questions/64107452
复制相似问题