Convert uploaded pdf to PIL image

Hello everyone.
I am developping an app to convert uploaded pdf’s into PIL images. I hope that someone can help me with a block of code at least or maybe some reference.
i tried pdfplumber.toimage - Got an error
tried pdf2image - gor an error

imagem_referencia = col1.file_uploader("", type=[‘jpg’, ‘jpeg’, ‘png’,‘pdf’,‘tiff’])
if imagem_referencia is not None:
if imagem_referencia.type == ‘application/pdf’:
with as pdf:

            imagemexibicao = col1.empty()
            col1.header(opcao + " original")
            imagemexibicao = col1.image(dtimgref, use_column_width=True)

i really apreciate the comunitty support, is awesome .

Pdf2image should work, check this code:

import streamlit as st
import pdf2image

imagem_referencia = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png", "pdf", "tiff"])
button = st.button("Confirm")

if button and imagem_referencia is not None:

    if imagem_referencia.type == "application/pdf":
        images = pdf2image.convert_from_bytes(
        for page in images:
            st.image(page, use_column_width=True)
1 Like

Hello francisco!!
Thank you so much for your answear!! You really helped me a lot!!!
Works perfectaly in my code!