lfoppiano / streamlit-pdf-viewer

Streamlit PDF viewer
https://structure-vision.streamlit.app/
Apache License 2.0
110 stars 8 forks source link

Dynamic resizing of pdf_viewer #74

Open trish11953 opened 3 weeks ago

trish11953 commented 3 weeks ago

If I add a pdf_viewer in a column in the Streamlit sidebar, the pdf_viewer does not use full container width to resize the pdf_viewer if the width of sidebar is changed. Is there a way to make it dynamic?

Odrec commented 3 weeks ago

I use this component to get the dimensions of the streamlit container the pdf viewer is in: https://github.com/avsolatorio/streamlit-dimensions

Then I do something like:

pdf_viewer(input=pdf,
           height=1000,
           width=int(container_dim['width'] * 0.4) if container_dim else 400,
           render_text=True)

That renders the pdf in a 40% of the width of the container it is in and also resizes with the container.