I want to convert a PDF (one page) into a PNG file.
I installed pdf2image and got this error:
popler is not installed in windows.
According to this question:
Poppler in path for pdf2image, Poppler should be installed and PATH modified.
I cannot do any of those (I don't have the necessary permissions in the system I am working with).
I had a look at OpenCV and PIL and none seems to offer the possibility to make this transformation: PIL (see here https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html?highlight=pdf#pdf) does not offer the possibility to read PDFs, only to save images as PDFs. The same goes for OpenCV.
Any suggestion on how to make the PDF to PNG transformation? I can install any Python library but I can not touch the Windows installation.
PyMuPDF supports pdf to image rasterization without requiring any external dependencies.
Sample code to do a basic pdf to png transformation:
import fitz # PyMuPDF, imported as fitz for backward compatibility reasons
file_path = "my_file.pdf"
doc = fitz.open(file_path) # open document
for i, page in enumerate(doc):
pix = page.get_pixmap() # render page to an image
pix.save(f"page_{i}.png")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With