Python: Convert a base64 encoded PDF file to a list of PIL (pillow) Images

Python: Convert a base64 encoded PDF file to a list of PIL (pillow) Images

motivation: generally images are easier to work with than PDF files.

import base64
import pdf2image
from PIL import Image

def convert_base64_encoded_pdf_to_PIL_image(pdf_base64: str) -> list[Image.Image]:
    pdf_bytes = base64.b64decode(pdf_base64)
    return pdf2image.convert_from_bytes(pdf_bytes)



Comments