amoldwalunj commited on
Commit
fd2d913
·
1 Parent(s): 610f8bb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -54,18 +54,15 @@ from io import BytesIO
54
  import tempfile
55
  from weasyprint import HTML
56
 
57
- def save_as_pdf(text):
58
- # Convert quill editor HTML to PDF
59
- with tempfile.NamedTemporaryFile(mode="w+", suffix=".html") as html_file:
60
- html_file.write(text)
61
- html_file.seek(0)
62
- pdf_file = BytesIO()
63
- HTML(filename=html_file.name).write_pdf(pdf_file)
64
-
65
- # Encode the PDF to base64
66
  b64 = base64.b64encode(pdf_file.getvalue()).decode('utf-8')
67
 
68
- # Generate a download link for the PDF
69
  href = f'<a href="data:application/octet-stream;base64,{b64}" download="output.pdf">Download PDF</a>'
70
  st.markdown(href, unsafe_allow_html=True)
71
 
 
54
  import tempfile
55
  from weasyprint import HTML
56
 
57
+ def save_as_pdf(quill_text):
58
+ # convert quill editor HTML to PDF
59
+ pdf_file = BytesIO()
60
+ HTML(string=quill_text).write_pdf(pdf_file)
61
+
62
+ # encode the PDF to base64
 
 
 
63
  b64 = base64.b64encode(pdf_file.getvalue()).decode('utf-8')
64
 
65
+ # generate a download link for the PDF
66
  href = f'<a href="data:application/octet-stream;base64,{b64}" download="output.pdf">Download PDF</a>'
67
  st.markdown(href, unsafe_allow_html=True)
68