amoldwalunj commited on
Commit
95f81ff
·
1 Parent(s): fd2d913

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -6
app.py CHANGED
@@ -49,15 +49,18 @@ def process_text(inputs):
49
 
50
 
51
 
52
- import base64
53
- from io import BytesIO
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')
@@ -67,6 +70,7 @@ def save_as_pdf(quill_text):
67
  st.markdown(href, unsafe_allow_html=True)
68
 
69
 
 
70
  def form_page():
71
 
72
  st.markdown("### Your custom obituary writer :pencil:")
 
49
 
50
 
51
 
52
+ import json
53
+ from quill.delta import Delta
54
+ from quill.renderer import Renderer
 
55
 
56
  def save_as_pdf(quill_text):
57
+ # convert quill delta format to HTML format
58
+ delta = Delta(json.loads(quill_text))
59
+ html = Renderer(delta).render()
60
+
61
+ # convert HTML to PDF
62
  pdf_file = BytesIO()
63
+ HTML(string=html).write_pdf(pdf_file)
64
 
65
  # encode the PDF to base64
66
  b64 = base64.b64encode(pdf_file.getvalue()).decode('utf-8')
 
70
  st.markdown(href, unsafe_allow_html=True)
71
 
72
 
73
+
74
  def form_page():
75
 
76
  st.markdown("### Your custom obituary writer :pencil:")