Currently, on my local, I’m able to successfully render PDF files onto my UI. However, as I’m trying to deploy the app I’m running into the PDF file not being shown on the UI.
As you can see through the inspect tools, the file’s component is being generated.
I can get this approach working on Safari without a problem, but the PDF does not render on Chrome - I think because of sandbox restrictions. Has anyone else encountered this problem? If so, were you able to come up with a code-based workaround?
same issue for me with a pdf viewer working like a charm on-premise but failing to display on Streamlit-cloud because blocked by chrome. Any update about it or any by-pass? Thx
I am having the same issue using base64 encoding on streamlit cloud. This code snippet works great locally but not on the cloud version. Note that the URL is HTTPS. Any ideas on how to get this to display on Streamlit cloud? Right now, it shows an empty iFrame.
#function to display the PDF of a given file
def displayPDF(file):
# Opening file from file path. this is used to open the file from a website rather than local
with urllib.request.urlopen(file) as f:
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
# Embedding PDF in HTML
pdf_display = F'<iframe src="data:application/pdf;base64,{base64_pdf}" width="700" height="950" type="application/pdf"></iframe>'
# Displaying File
st.markdown(pdf_display, unsafe_allow_html=True)
Last time I tried it worked in Edge (uses blink, does that make it qualify as a Chromium browser?) and Gnome Web (webkit, like Safari). Unfortunately I am unable to test Cromium and Safari.