首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >python“可能不是pdf2image文件”错误

python“可能不是pdf2image文件”错误
EN

Stack Overflow用户
提问于 2022-04-10 07:32:54
回答 1查看 456关注 0票数 0

在Centos 8操作系统上,我在用Python将pdf页面转换为jpg文件时出错。

代码语言:javascript
运行
复制
from pdf2image import convert_from_path
import sys

images = convert_from_path("test.pdf",500)
for i in range(len(images)):
    images[i].save('page'+ str(i) +'.jpg', 'JPEG')

因此,它给出了这个错误。我可以在本地运行PDF文件,但是当我想将它保存为一个jpg时,它不能工作。

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pdf2image/pdf2image.py", line 479, in pdfinfo_from_path
    raise ValueError
ValueError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "pdf_conv.py", line 7, in <module>
    images = convert_from_path(pdf_path,500)
  File "/usr/local/lib/python3.6/site-packages/pdf2image/pdf2image.py", line 98, in convert_from_path
    page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
  File "/usr/local/lib/python3.6/site-packages/pdf2image/pdf2image.py", line 489, in pdfinfo_from_path
    "Unable to get page count.\n%s" % err.decode("utf8", "ignore")
pdf2image.exceptions.PDFPageCountError: Unable to get page count.
Syntax Warning: May not be a PDF file (continuing anyway)
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't find trailer dictionary
Syntax Error: Couldn't read xref table
EN

回答 1

Stack Overflow用户

发布于 2022-04-10 07:51:17

PDF != PDF -有不同的版本。可能您的python pdf2image不喜欢/知道您提供给它的PDF类型。使用AcrobatReader或其他类似的工具来检查您要转换的内容,并查看pdf2image是否支持它。

pdf2image支持哪些标准? (简称:pdf2image支持波普尔所支持的所有PDF标准。)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71814599

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档