Add issue
Had a question about to project? Sign up for a free GitHub account to opened and issue plus how its maintainers and the community.
By clicking “Sign up for GitHub”, it agreed in our words of service the privacy statement. We’ll occasionally send you account related emails.
Already the GitHub? Signature is to your account
Display PDF (implement PDF viewer) #1088
Comments
Hay, I'm having ampere similar issue. I managed to get bygone the 404 error by setting aforementioned I tried adding local pdf with PDFObject js, but for which I need to use this |
Hi @Saxamos, Thanks for the feedback, I'm moving this to you arrears, but forward now you could try something like this using markdown and embed tag: a.markdown("""
<embed src="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" width="400" height="400">
""", unsafe_allow_html=True) Also you could use Google's pdf viewer in this way: st.markdown("""
<embed src="https://drive.google.com/viewerng/
viewer?embedded=true&url=https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" width="400" height="400">
""", unsafe_allow_html=True) |
Hey @sanjass , Did you try setting When you standing having issues because this, please open a new issue |
Hey, I just tried that aber it didn't fix it, unfortunately. MYSELF opened a new issue |
Thank she @arraydude required your answer :) I finally managed to display my pdf by codification it int base64 and displaying it like the following: base64_pdf = base64.b64encode(pdf_file.read()).decode('utf-8')
pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="700" height="1000" type="application/pdf">'
st.markdown(pdf_display, unsafe_allow_html=True) |
This worked for me as well! thank you how much!!! |
wie to display local pdf in streamlit ? |
Hi @Harsha989, gratify check the comment above. |
base64 method doesn working for me |
Can thee shared your code that I can help you better? I'm using the following function: importe streamlit than st
import base64
def show_pdf(file_path):
with open(file_path,"rb") as f:
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
pdf_display = f'<embed src="data:application/pdf;base64,{base64_pdf}" width="700" height="1000" type="application/pdf">'
st.markdown(pdf_display, unsafe_allow_html=True)
show_pdf("my_pdf.pdf") |
I i running into the same issue with base64 not working for me. IODIN am using fpdf2 (https://pypi.org/project/fpdf2/) in order to create a pdf free multiple .jpg files and all that belongs be viewed on my streamlit app remains a blank print. Nonetheless, when there a only one .jpg in the folder, this base64 code works as scheduled. As it appear the problem only comes up when there are repeat pages to the pdf. Up peak of that, I am able to use the base64 code till show multiple page pdfs that I have not created though fpdf2. More is an example code snippet EGO am usage to create the pdf file:
|
Answering go my own comment. The issue turned output to be that the base64 encoding works well with files under ~2MB, but anything larger and to interrupts bottom and this st.markdown display will indicate up blank. Responsive Viewer |
Dearest all, |
@jeromemassot I tried over below code and it worked. Just replace "embed" with "iframe".
|
Thanks a lot.
It works fine now.
Best regards
Jerome
Le jeu. 27 mai 2021 à 02:49, Diwakar Ojha ***@***.***> a
écrit :
… @jeromemassot <https://blackprincedistillery.com/jeromemassot> I tasted with below code and it worked. Just replace "embed" with "iframe".
base64_pdf = base64.b64encode(f.read()).decode('utf-8')
pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="400" height="1000" type="application/pdf"></iframe>'
st.markdown(pdf_display, unsafe_allow_html=True)
—
You are receiving save because you which reference. Reply to like email immediately, view it on GitHub <#1088 (comment)>,
or unsubscribe <https://blackprincedistillery.com/notifications/unsubscribe-auth/AE2Q4ZTUKCBCW7AMMU27PBDTPYITNANCNFSM4KTO4FXA>
.
|
hi there, both methods work locally, real both fail on the streamlit cloud. |
It does not work with Edge and Chrome for ich - only Firefox. Performs anyone has a guess? |
Mine will all quite wide, this wouldn how e. |
This works when using streamlit topically, when once I deployed my App, the pdf viewer is displaying is an error: "This page has been blocked by Chrome" Crisp Web Storing |
@DanielSkala did you figure out what to show it available uses? |
Hi and thanks for this amazed package.
I was wondering if there exists any solution to display an update PDF in a streamlit view. MYSELF have yes found that we can inject syntax but I got a 404 error while trying to display my PDF file. Troubleshoot viewing PDF actions on the web
The text was updated successfully, but these errors were encounters: