Spaces:
Runtime error
Runtime error
Commit
·
fd2d913
1
Parent(s):
610f8bb
Update app.py
Browse files
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(
|
58 |
-
#
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
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 |
-
#
|
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 |
|