Hi All,
In jupyter notebook
%%html
href="…/files/Downloads/jaipur.pdf#page=10" target="_blank">Link to a pdf
creates a link pointing towards pdf file and when clicked opens pdf in new tab.
How I can create a html link to open file using streamlit ?
2 Likes
Hi @kamal_kumawat
Have you checked this hack from @ash2shukla ?
Hi @Pavan_Cheyutha ,
You sure can !
Though streamlit doesnt support PDF generation out of the box for obvious reasons but you can look into PyFPDF and coupled with streamlit it can do the job. Adding a snippet that I just tried for reference.
import streamlit as st
from fpdf import FPDF
import base64
report_text = st.text_input("Report Text")
export_as_pdf = st.button("Export Report")
def create_download_link(val, filename):
b64 = base64.b64encode(val) # val looks like b'...'
retu…
Thanks
Charly
2 Likes
Hm this seems to download the PDF, but is there a way for the user to just open it in a new tab without downloading?
1 Like
What this ever solved? I have a similar use case where I’d like the link on my Streamlit page to open a local file (like a pdf) for further inspection outside of Streamlit.
3 Likes
I’d like a user to be able to click a link and open Windows Explorer to the folder provided in the link. Is this possible?
3 Likes
funcode
February 13, 2024, 5:00am
6
I’m also looking for a solution. Is there a way to create a link to a local folder in streamlit?
3 Likes
mucmch
February 24, 2024, 8:07pm
7
Also looking for a way to open a specific folder locally on windows using streamlit.
1 Like
beyma
September 6, 2024, 8:52am
8
Same here, also interested in an easy way to open a new tab to render a pdf