Problems displaying pdf in Streamlit Cloud

Greetings. I’m working on a Streamlit app that allows users to pose questions to GPT-3 about a historical text. I’ve recently moved my Python script to Streamlit cloud, and everything works well except rendering the pdf. Below is a screenshot, and here is a link to the app:

The pdf displays correctly when I run it locally, but no luck with Streamlit Cloud. I’ve tried multiple methods (here, here respectively), and here), and tried loading the pdf directly from the web, from Github, and from Google Drive. None seem to work. Here’s my code for displaying the pdf.

st.title("Ask A Source: Thomas More's 'The History of Richard III'")
col1, col2 = st.columns([2,3])
with col1:

    #method 1
    pdf_url = ''
    pdf_display = F'<iframe src="{pdf_url}" width="700" height="700" type="application/pdf"></iframe>'
    st.markdown(pdf_display, unsafe_allow_html=True)

    #method 2
    <embed src="" width="800" height="800">
    """, unsafe_allow_html=True)
    #pdf_display = F'<iframe src="" width="700" height="1000" type="application/pdf"></iframe>'

Any ideas on how to proceed?

1 Like

Your method 2 works for me in Streamlit Cloud.

Thanks very much for the reply. Unfortunately, all I get is an empty frame or or a message indicating Chrome is blocking the file (I’ve tried the same thing for Github and Google Drive, all with the same error)

I clicked your app link and the pdf is showing fine for me. What browser are you using? Can you try private/incognito windows? Can you try other browsers? Maybe you need to clear your browser cache or you have a security setting that is blocking it.

1 Like

Thank you very much for checking it! For some reason it doesn’t display on my computers hooked up to my college’s network, but also displays fine on my phone(!). This will give me some options to see what’s going on. Thank you!

1 Like

Can I ask which browser you used? I’m using Chrome and Edge with no luck so far.

I opened it in Firefox without an issue. I do see that it isn’t loading in Chrome and Edge, though. (Edge being built on Chromium, of course.)

Can you try changing the source to the raw link:

any updates @Daniel_Hutchinson on how you rendered it on streamlit cloud? I tried Chrome and i got the same thing and for safari it doesn’t even show lol.

This is how I’m rendering it

def show_pdf(folder_name, file_name):

    with tempfile.NamedTemporaryFile("wb") as f_src:"Downloading {file_name}...")

        with open(, "rb") as f:
            base64_pdf = base64.b64encode("utf-8")

        pdf_display = f"""
            width="100%" height="1000"
            style="min-width: 400px;"

        st.markdown(pdf_display, unsafe_allow_html=True)

Have you found a solution? I have the same problem. It only works in firefox.

I have also tried to display a PDF file in browser, and I failed in Chrome and Edge. It only works well on Firefox.

Please, check this out: GitHub - lfoppiano/streamlit-pdf-viewer: Streamlit PDF viewer

it’s a new component we are developing for viewing PDF documents in streamlit