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.
Hi there, im trying to highlight sentences on the PDF that is rendered.
Is there a way i can input a sentence through the UI and then have it highlighted in the rendered PDF. i know there is a search icon which does the same thing, but please share the code.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.