discuss.streamlit.io Open in urlscan Pro
184.105.99.75  Public Scan

URL: https://discuss.streamlit.io/t/pdf-display-blocked-by-chrome/22763
Submission: On December 27 via manual from PT — Scanned from PT

Form analysis 1 forms found in the DOM

POST /login

<form id="hidden-login-form" method="post" action="/login" style="display: none;">
  <input name="username" type="text" id="signin_username">
  <input name="password" type="password" id="signin_password">
  <input name="redirect" type="hidden">
  <input type="submit" id="signin-button" value="Log In">
</form>

Text Content

Skip to main content

 * About Streamlit
 * About
 * Explore
 * Docs
 * Blog

Log In
 * 
   
   




DISCUSS

Ask the community, share ideas, and connect with other Streamlit users!

 * Topics
   
   
   
   
 * More
   

Categories
 * Official Announcements
 * Using Streamlit
 * Show the Community!
 * Community Cloud
 * Custom Components
 * Events
 * Streamlit and Snowflake
 * Jobs
 * All categories

Tags
 * cache
 * llms
 * pandas
 * session-state
 * streamlit-cloud
 * All tags




PDF DISPLAY BLOCKED BY CHROME

Community Cloud


You have selected 0 posts.

select all

cancel selecting

3.1k views 3 links 17 users
2






Mar 2022
1 / 18
Mar 2022

Nov 20

Jerome_MASSOT
Mar 2022


Hi everyone,
I have the following issue with my app after deployment on Streamlit Cloud : I
display a pdf file by giving its URL by using a markdown component located in an
expander component. It works fine locally and I have read posts about the
difference between using an iframe vs. embed. But once running in the cloud, I
cannot display the pdf as the “page has been blocked by Chrome”.
Any idea?
Thanks and have a good week-end
Jerome

1 Reply

4



3.1k views 3 links 17 users
2







2 months later
Tushar_Bhatnagar
May 2022


I am struggling with the same but I couldn’t find any solution to this.





2 months later
WaterKnight
Jul 2022


@Jerome_MASSOT @Tushar_Bhatnagar how did you solve this in the end??





14 days later
HO_Tuong_Vinh
Jul 2022


I got the same issue.
Search and read a lot but can’t find a solution.
I can display PDF with Firefox but Chrome and Safari.

Any suggestion ?
Thanks





3 months later
uday_khanna
Oct 2022


Did you manage to fix it ? I am stuck with the same situation





5 months later
zmazz
Mar 2023


looking for solution here as well, if anybody found a solution since then





20 days later
adarshxs
Apr 2023


Anyone with any solution?? please help!





3 months later
roy.zohar.40
Jun 2023


Also having the exact same issue, nothing works …
Please help!





3 months later
Mahantesh_Hiremath
Sep 2023


Nothing works !!!





caiopjv
Sep 2023


I have the same problem. My app works only in firefox. Waiting for a solution





10 days later
cehaoyang
Sep 2023


Me too. It only works on Firefox. Failed on Edge and Chrome





varun_chindage
Sep 2023


Jerome_MASSOT:

> have the following issue with my app after deployment on Streamlit Cloud : I
> display a pdf file by giving its URL by using a markdown component located in
> an expander component. It works fine locally and I have read posts about the
> difference between using an iframe vs. embed. But once running in the cloud, I
> cannot display the pdf as the “page has been blocked by Chrome”.
> Any idea?
> Thanks and have a good week-end
> Jerome

you can try converting it to jpg and the upload?





8 days later
SidmoGoesBrrr
Oct 2023


You can try converting it to a jpeg and also adding a button to download the pdf





cehaoyang
Oct 2023


I suddenly found a way. Directly pass base64 strings as content of PDF is very
redundant.

Using url like “src=http://localhost:8900/filename.pdf” is a much more relaxed
way. Therefore, we can choose directly store the pdf file uploaded by user:

uploaded_file = st.sidebar.file_uploader(
    label="Upload PDF files", type=["pdf"], accept_multiple_files=False
)

if not uploaded_file:
    st.session_state.clear()
    st.info("请在左侧上传您的PDF文件")
    st.stop()

@st.cache_resource(ttl="1h")
def configure_PDF(file):
    with open(os.path.join("/your_path/user_upload_pdfs", file.name), "wb") as f:
        f.write(uploaded_file.getvalue())


The next step is to start up a HTTP server locally by:

> python -m http.server 8900

at /your_path/user_upload_pdfs.

Then files can be accessed by ‘http://localhost:8900/filename.pdf’

Finally, with any type of component like “embed”, “iframe” or “object” to view a
PDF in Browser, writing HTML like:

> embed src=“http://localhost:8900/{file.name}” type=“application/pdf”
> width=“1000px” height=“1100px”

In a production environment considering privacy, you can do more development on
the HTTP server that temporarily stores PDF files.

1 Reply





Pq6EScFdI2Nz1oF
1
Oct 2023


Can you share an example of what streamlit function you used to render the PDF?
For example I tried (with no success):

pdf_display_http = f'<embed src=“http://localhost:8900/{file.name}” type=“application/pdf” width=“1000px” height=“1100px”></embed>'

st.markdown(pdf_display_http, unsafe_allow_html=True)


Where the PDF should be, the app says localhost refused to connect.





6 months later
MossDaBoss
cehaoyang
Apr 20


How does it work when you deploy in cloud say streamlt community cloud ?





5 months later
Bruno5
Sep 26


The interesting thing is that it worked on my Iphone using Chrome





2 months later
Shady
Nov 20


I hope Streamlit can make a solution for this big problem!









THIS TOPIC WILL CLOSE A YEAR AFTER THE LAST REPLY.


Reply




RELATED TOPICS

Topic list, column headers with buttons are sortable. Topic Replies Views
Activity Embedding pdf base64 is blocked by google chrome
Community Cloud
debuggingpdf-viewer
3 669 Aug 5

Rendering PDF on UI
Using Streamlit
29 32.6k Jun 25

Embed and iframe PDF not showing when deployed to Cloud
Community Cloud
streamlit-cloud
4 1.1k Feb 2023

Workaround the sandbox in Chrome
Custom Components
discussionchrome
1 432 Mar 5 Problems displaying pdf in Streamlit Cloud
Community Cloud
streamlit-cloud
11 2.6k Nov 20




 * Cookie settings
 * Privacy policy
 * Terms of use
 * Contact








Invalid date Invalid date







HELLO THERE 👋🏻

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 Reject all Accept all


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.

Reject all Accept all