'I am trying to use pdf2image but I am getting this error
Traceback (most recent call last):
File "C:\Users\Balmeet\PycharmProjects\text&checkBox\venv\lib\site-packages\pdf2image\pdf2image.py", line 441, in pdfinfo_from_path
proc = Popen(command, env=env, stdout=PIPE, stderr=PIPE)
File "C:\Users\Balmeet\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "C:\Users\Balmeet\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1155, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/Balmeet/PycharmProjects/tables/final.py", line 470, in <module>
pdf2img2.convert_to_image(pdf_file)
File "C:\Users\Balmeet\PycharmProjects\tables\pdf2img2.py", line 42, in convert_to_image
pages = convert_from_path(pdf_file, 600)
File "C:\Users\Balmeet\PycharmProjects\text&checkBox\venv\lib\site-packages\pdf2image\pdf2image.py", line 97, in convert_from_path
page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
File "C:\Users\Balmeet\PycharmProjects\text&checkBox\venv\lib\site-packages\pdf2image\pdf2image.py", line 468, in pdfinfo_from_path
"Unable to get page count. Is poppler installed and in PATH?"
pdf2image.exceptions.PDFInfoNotInstalledError: Unable to get page count. Is poppler installed and in PATH?
I have followed steps mentioned in the similar post and set path for poppler but still getting this error thanks in advance:)
Solution 1:[1]
Download Poppler and save it in your folder where u have scripts and try executing with below.
from pdf2image import convert_from_path
pages = convert_from_path(f'dummy.pdf', poppler_path='poppler-20.12.1\\bin')
for page in pages:
n = 1
page.save(f'page{n}.png', 'PNG')
n += 1
I have tested this and I got the pdf file converted to image.
Solution 2:[2]
adding this to code working for me, please download poppler from here and extract https://blog.alivate.com.au/poppler-windows/
pages = convert_from_path('document1.pdf', poppler_path='C:/Users/poppler-0.68.0/bin')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Prakash |
| Solution 2 | jasraj |
