Python Forum
pdf2image, poppler and paths
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pdf2image, poppler and paths
#1
I need to run some tests on converting PDF's to images. The article at https://medium.com/towards-data-science/...670ee38052 has been quite helpful.

I have pdf2image, poppler, poppler-utils, etc installed. I have used the code at https://gist.github.com/akash-ch2812/1e2...o_Image.py

from pdf2image import convert_from_path

pdfs = r"provide path to pdf file"
pages = convert_from_path(pdfs, 350)

i = 1
for page in pages:
    image_name = "Page_" + str(i) + ".jpg"  
    page.save(image_name, "JPEG")
    i = i+1     
Error:
$ python3 PDF_to_Image.py Tests_20220530.pdf Traceback (most recent call last): File "/home/********/.local/lib/python3.9/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 "/home/********/Downloads/OCR/PDF_to_Image.py", line 4, in <module> pages = convert_from_path(pdfs, 350) File "/home/********/.local/lib/python3.9/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 "/home/********/.local/lib/python3.9/site-packages/pdf2image/pdf2image.py", line 488, in pdfinfo_from_path raise PDFPageCountError( pdf2image.exceptions.PDFPageCountError: Unable to get page count. I/O Error: Couldn't open file 'provide path to pdf file': No such file or directory.
So, have tried various versions of specifying the path and/or filename at line 3, all to no avail. Not sure how to determine if 'poppler' is in the PATH, however a 'locate' shows it is installed.

I have looked through the issues from "pdf2image" and problem not solved.

Does this script simply need the "poppler" path and how do I find that ? Also, surely the code can be modified so that a parameters is parsed to specify path/directories. The PDF is in the same path as the script, so I assume the script is failing because it doesn't know where "poppler" is found.
Reply


Messages In This Thread
pdf2image, poppler and paths - by jehoshua - Jun-11-2022, 02:21 AM
RE: pdf2image, poppler and paths - by Larz60+ - Jun-11-2022, 02:38 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-11-2022, 04:20 AM
RE: pdf2image, poppler and paths - by DPaul - Jun-11-2022, 05:56 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-11-2022, 07:08 AM
RE: pdf2image, poppler and paths - by Larz60+ - Jun-11-2022, 09:10 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-11-2022, 11:30 PM
RE: pdf2image, poppler and paths - by snippsat - Jun-11-2022, 10:34 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-11-2022, 11:40 PM
RE: pdf2image, poppler and paths - by Larz60+ - Jun-12-2022, 01:56 PM
RE: pdf2image, poppler and paths - by jehoshua - Jun-13-2022, 03:23 AM
RE: pdf2image, poppler and paths - by Larz60+ - Jun-13-2022, 07:17 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-13-2022, 08:16 AM
RE: pdf2image, poppler and paths - by Larz60+ - Jun-13-2022, 11:04 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-13-2022, 09:52 PM
RE: pdf2image, poppler and paths - by Larz60+ - Jun-13-2022, 10:42 PM
RE: pdf2image, poppler and paths - by jehoshua - Jun-13-2022, 10:44 PM
RE: pdf2image, poppler and paths - by snippsat - Jun-14-2022, 12:46 AM
RE: pdf2image, poppler and paths - by jehoshua - Jun-14-2022, 06:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Windows paths issue otalado 3 1,526 May-29-2022, 09:11 AM
Last Post: snippsat
  automatically get absolute paths oclmedyb 1 2,143 Mar-11-2021, 04:31 PM
Last Post: deanhystad
  chkFile with absolute paths JarredAwesome 7 3,055 Sep-21-2020, 03:51 AM
Last Post: bowlofred
  Paths millpond 12 5,304 Jul-30-2020, 01:16 PM
Last Post: snippsat
  Problems with windows paths delphinis 6 5,319 Jul-21-2020, 06:11 PM
Last Post: Gribouillis
  'No module named pdf2image' ironfelix717 13 22,469 Jul-24-2019, 11:54 AM
Last Post: snippsat
  Shortest paths to win snake and ladder sandaab 5 4,322 Jun-30-2019, 03:20 PM
Last Post: sandaab
  How to handle paths with spaces in the name? zBernie 1 6,791 Nov-22-2018, 04:04 AM
Last Post: ichabod801
  Question: Paths and writing to a file mwmaw 6 6,608 Dec-20-2016, 03:44 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020