我想在Mac OS X上使用python中的pdf2image将pdf转换为图像。
from pdf2image.exceptions import (
PDFInfoNotInstalledError,
PDFPageCountError,
PDFSyntaxError
)
# define pdf path
pdf_path = "./pdf_file/ooo.pdf"
# convert pdf to image(1200dpi)
images = convert_from_path(str(pdf_path), 1200)
# save image files one by one
image_dir = "./image_file"
for i, image in enumerate(images):
file_name = pdfpath + "{:02d}".format(i + 1) + ".jpeg"
image_path = image_dir / file_name
# save JPEG
image.save(str(image_path), "JPEG")
然后我收到类似这样的错误消息
TypeError Traceback (most recent call last)
<ipython-input-19-26e2710189ca> in <module>
13 for i, image in enumerate(images):
14 file_name = pdfpath + "{:02d}".format(i + 1) + ".jpeg"
---> 15 image_path = image_dir / file_name
16 # save JPEG
17 image.save(str(image_path), "JPEG")
TypeError: unsupported operand type(s) for /: 'str' and 'str'
我不明白发生了什么。 请帮忙!