i want to convert my whole streamlit page to pdf when i click on my streamlit or html embedded button any ideas ??like when i click button it should give me the link to download the pdf of whole streamlit page
Hi @Ahsan_Naqvi,
Thanks for posting!
Have you checked out these threads?
- Creating a PDF file generator
- Is there a way to convert the page that is viewed to a pdf
- Hack to save page as html or pdf
Caroline
I have checked these out but this didn’t worked out… actually i have a dashboard having bookeh charts and plotly graphs i want to add a stream lit button in my streamlit webpage so whenever i click my button it gives me option to download the whole webpage on which there is dash board i have tried many things out but it didn’t helped me
I checked out first link in which creator have saved the figures using fig.savefigure() command and then putted them in pdf … i can try that one out but i aslo have bookeh charts in my dashboard how can we save them like we have saved figures please help me out thanks
Hi @Ahsan_Naqvi,
This thread seems to have a pretty good example of converting a bokeh chart to a PDF. Pasting the code snippet below.
from bokeh.plotting import figure
from bokeh.io import export_svgs
import svglib.svglib as svglib
from reportlab.graphics import renderPDF
test_name = 'bokeh_to_pdf_test'
# Example plot p
p = figure(plot_width=400, plot_height=400, tools="")
p.circle(list(range(1,6)),[2, 5, 8, 2, 7], size=10)
# See comment 1
p.xaxis.axis_label_standoff = 12
p.xaxis.major_label_standoff = 12
# step 1: bokeh save as svg
p.output_backend = "svg"
export_svgs(p, filename = test_name + '.svg')
# see comment 2
svglib.register_font('helvetica', '/home/fonts/Helvetica.ttf')
# step 2: read in svg
svg = svglib.svg2rlg(test_name+".svg")
# step 3: save as pdf
renderPDF.drawToFile(svg, test_name+".pdf")
Caroline
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.