Spaces:
Runtime error
Runtime error
Commit
·
65a1858
1
Parent(s):
f4e74e3
Update app.py
Browse files
app.py
CHANGED
@@ -189,26 +189,31 @@ def form_page():
|
|
189 |
|
190 |
|
191 |
def editor_page():
|
192 |
-
#st.markdown("### Editor :smile:")
|
193 |
st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
|
194 |
-
|
195 |
st.write("Use the editor below to edit the obituary:")
|
196 |
-
|
197 |
quill_text = st.session_state.output_text
|
198 |
edited_text = st_quill(quill_text)
|
199 |
-
|
200 |
st.write("Here is the edited obituary:")
|
201 |
#st.write(edited_text)
|
202 |
-
|
203 |
st.session_state.edited_text = edited_text
|
204 |
-
|
205 |
if st.button("Download as PDF"):
|
206 |
# Save edited text as HTML string
|
207 |
-
html_string = f"<html><head><style>{edited_text
|
208 |
# Save HTML string as PDF file and generate download link
|
209 |
with st.spinner("Generating PDF..."):
|
210 |
pdf_file = save_as_pdf(html_string)
|
211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
|
213 |
|
214 |
|
|
|
189 |
|
190 |
|
191 |
def editor_page():
|
|
|
192 |
st.markdown("<h1 style='text-align: center; color: Red;'>Editor</h1>", unsafe_allow_html=True)
|
|
|
193 |
st.write("Use the editor below to edit the obituary:")
|
194 |
+
|
195 |
quill_text = st.session_state.output_text
|
196 |
edited_text = st_quill(quill_text)
|
197 |
+
|
198 |
st.write("Here is the edited obituary:")
|
199 |
#st.write(edited_text)
|
|
|
200 |
st.session_state.edited_text = edited_text
|
201 |
+
|
202 |
if st.button("Download as PDF"):
|
203 |
# Save edited text as HTML string
|
204 |
+
html_string = f"<html><head><style>{edited_text['css']}</style></head><body>{edited_text['content']}</body></html>"
|
205 |
# Save HTML string as PDF file and generate download link
|
206 |
with st.spinner("Generating PDF..."):
|
207 |
pdf_file = save_as_pdf(html_string)
|
208 |
+
with open(pdf_file, "rb") as f:
|
209 |
+
pdf_bytes = f.read()
|
210 |
+
st.download_button(
|
211 |
+
label="Download PDF",
|
212 |
+
data=pdf_bytes,
|
213 |
+
file_name="edited_text.pdf",
|
214 |
+
mime="application/pdf",
|
215 |
+
)
|
216 |
+
|
217 |
|
218 |
|
219 |
|