Closed solita-tsjoberg closed 2 months ago
Thanks! Opening the PDF at a specific page would come a very handy feature. However, my experience with streamlit is not deep and moving to a specific page means scrolling down the PDF to a certain place. I'm currently not sure how this could or should be implemented, but I'm happy to follow suggestions.
Have not delved too deep into your code, but before swapping to your code we used something like this:
import base64
import streamlit as st
import fitz
if __name__ == "__main__":
file = fitz.open(file, filetype="pdf")
file = file.write()
base64_pdf = base64.b64encode(file).decode("utf-8")
st.markdown(
f'<iframe src="data:application/pdf;base64,{base64_pdf}#page={page_number}" type="application/pdf"></iframe>',
)
)
Where we used the #page=page_number
that seems to be part of some standard pdf string.
This would not require any scrolling if you use this kind of string somewhere!
Thanks!
@solita-tsjoberg are you using the rendering=legacy_iframe
or legacy_embed
?
We could easily add this parameter to it, but this method works only on a small subset of browsers when used by a separate component. In fact, I was thinking to remove it completely at some point, but it seems it's still used more than I though. 🤔
Neither, we are using the default unwrap
rendering.
As stated in the title, I would love the feature to be able to open the full PDFs at a specific page.
In my usecase we settled on filtering out the specific page we wanted to open at, but opening at the right page would be much smoother.