Welcome to streamlit-pdf-viewer Discussions! #59
Replies: 7 comments 6 replies
-
I'm trying to create an expander for each page in a PDF, but I'm unable to achieve this using the following code. Can you help me? |
Beta Was this translation helpful? Give feedback.
-
Great component. However, the scroll_to_page doesn't work when height is specified. |
Beta Was this translation helpful? Give feedback.
-
Hi Luca,
I’ll try wrapping within container.
Here’s my test code:
import streamlit as st from streamlit_pdf_viewer import pdf_viewer # Path
to the PDF file folder = "pdfs" filename =
"77_yr_breathing_swallowing_difficulty.pdf" pdf_path =
f"{folder}/{filename}" # Streamlit app title st.title("PDF Viewer - Using
Binary Data") st.write(f"{pdf_path}") # Read the PDF as binary data try:
with open(pdf_path, "rb") as pdf_file: pdf_bytes =
pdf_file.read() # Pass the binary data directly to pdf_viewer #
pdf_viewer(pdf_bytes, scroll_to_page=3, width=700, height=700) except
FileNotFoundError: st.error(f"File not found: {pdf_path}")
Thanks and best regards, Nihal
…On Thu, Nov 21, 2024 at 1:09 AM Luca Foppiano ***@***.***> wrote:
hi @drnihalmehta <https://github.com/drnihalmehta>, can you share me the
code you're using where the scroll_to_page does not work?
Alternatively you can avoid specifying the height and wrap the component
into a st.container:
with st.container(height=xyz):
pdf_viewer(....
—
Reply to this email directly, view it on GitHub
<#59 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT4FXBWYYLZWTR2VYJE5QKL2BWBKNAVCNFSM6AAAAABMB34JPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMZTGI4DAOI>
.
You are receiving this because you were mentioned.Message ID:
<lfoppiano/streamlit-pdf-viewer/repo-discussions/59/comments/11332809@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Ok. I’ll send you the .py file itself shortly where it’s
properly formatted.
I cut and pasted into the email and it’s showing up nicely on my end.
Sorry about that.
Thanks and best regards, Nihal
…On Thu, Nov 21, 2024 at 7:29 AM Luca Foppiano ***@***.***> wrote:
Sorry can't you please take some time to format it properly? I can't read
it
—
Reply to this email directly, view it on GitHub
<#59 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT4FXBXY6RXGIMRG2TCZUDT2BXN2BAVCNFSM6AAAAABMB34JPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMZTGY2DQOI>
.
You are receiving this because you were mentioned.Message ID:
<lfoppiano/streamlit-pdf-viewer/repo-discussions/59/comments/11336489@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Here's the sample test file I'm using.
Also, it doesn't work when using a URL for the location of the PDF
location.
Both cases are in this file.
Thanks for your help.
Thanks and best regards,
Nihal
Nihal J. Mehta, Ph.D.
***@***.***
…On Thu, Nov 21, 2024 at 1:09 AM Luca Foppiano ***@***.***> wrote:
hi @drnihalmehta <https://github.com/drnihalmehta>, can you share me the
code you're using where the scroll_to_page does not work?
Alternatively you can avoid specifying the height and wrap the component
into a st.container:
with st.container(height=xyz):
pdf_viewer(....
—
Reply to this email directly, view it on GitHub
<#59 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT4FXBWYYLZWTR2VYJE5QKL2BWBKNAVCNFSM6AAAAABMB34JPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCMZTGI4DAOI>
.
You are receiving this because you were mentioned.Message ID:
<lfoppiano/streamlit-pdf-viewer/repo-discussions/59/comments/11332809@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Here is the code. Thanks again.
|
Beta Was this translation helpful? Give feedback.
-
I got it to work using st.container as you suggested.
Thanks and best regards, Nihal
…On Sun, Dec 1, 2024 at 2:14 PM Luca Foppiano ***@***.***> wrote:
@drnihalmehta <https://github.com/drnihalmehta> is it working?
—
Reply to this email directly, view it on GitHub
<#59 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT4FXBTOOFEJL5YH3TPUYT32DNU2FAVCNFSM6AAAAABMB34JPGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTCNBTGAYTSOI>
.
You are receiving this because you were mentioned.Message ID:
<lfoppiano/streamlit-pdf-viewer/repo-discussions/59/comments/11430199@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
👋 Welcome!
We’re using Discussions as a place to connect with other members of our community. We hope that you:
build together 💪.
To get started, comment below with an introduction of yourself and tell us about what you do with this community.
Beta Was this translation helpful? Give feedback.
All reactions