I want to convert pdf to image using pdf2image in python on Mac OS X.
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")
then I get the error message like
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'
I cannot understand what is happening. Please help!