Belval / pdf2image

A python module that wraps the pdftoppm utility to convert PDF to PIL Image object
MIT License
1.6k stars 194 forks source link

I try to convert every pdf pages into separate jpg images i get pdfinfo.exe - system error #148

Open udara4 opened 4 years ago

udara4 commented 4 years ago
from pdf2image import convert_from_path, convert_from_bytes
from pdf2image.exceptions import (
    PDFInfoNotInstalledError,
    PDFPageCountError,
    PDFSyntaxError
)

images = convert_from_path(r"path", output_folder=r"path" , fmt="jpg")

When I run this I get this error message

ValueError                                Traceback (most recent call last)
~\Anaconda3\lib\site-packages\pdf2image\pdf2image.py in pdfinfo_from_path(pdf_path, userpw, poppler_path)
    435         if "Pages" not in d:
--> 436             raise ValueError
    437 

ValueError: 

During handling of the above exception, another exception occurred:

PDFPageCountError                         Traceback (most recent call last)
<ipython-input-3-f0c38cb2bf94> in <module>
----> 1 images = convert_from_path(r"C:\Users\UdAra\MSc codes\151-180\151.pdf", output_folder=r"C:\Users\UdAra\MSc codes\151-180" , fmt="jpg")

~\Anaconda3\lib\site-packages\pdf2image\pdf2image.py in convert_from_path(pdf_path, dpi, output_folder, first_page, last_page, fmt, jpegopt, thread_count, userpw, use_cropbox, strict, transparent, single_file, output_file, poppler_path, grayscale, size, paths_only, use_pdftocairo)
     92         poppler_path = poppler_path.as_posix()
     93 
---> 94     page_count = pdfinfo_from_path(pdf_path, userpw, poppler_path=poppler_path)["Pages"]
     95 
     96     # We start by getting the output format, the buffer processing function and if we need pdftocairo

~\Anaconda3\lib\site-packages\pdf2image\pdf2image.py in pdfinfo_from_path(pdf_path, userpw, poppler_path)
    444     except ValueError:
    445         raise PDFPageCountError(
--> 446             "Unable to get page count.\n%s" % err.decode("utf8", "ignore")
    447         )
    448 

PDFPageCountError: Unable to get page count.

These links describes my issue.

Annotation 2020-07-12 023138 Annotation 2020-07-12 023428

Belval commented 4 years ago

Where did you get poppler from? This is pretty bad because you seem to be missing the JPEG library.