Spaces:
Sleeping
Sleeping
Update exporters.py
Browse files- exporters.py +4 -8
exporters.py
CHANGED
|
@@ -9,18 +9,14 @@ DOCX_PATH = "/mnt/data/IdeaBrief.docx"
|
|
| 9 |
def export_pdf(text: str) -> str:
|
| 10 |
styles = getSampleStyleSheet()
|
| 11 |
doc = SimpleDocTemplate(PDF_PATH)
|
| 12 |
-
|
| 13 |
-
content = []
|
| 14 |
-
for line in text.split("\n"):
|
| 15 |
-
content.append(Paragraph(line if line.strip() else " ", styles["Normal"]))
|
| 16 |
-
|
| 17 |
doc.build(content)
|
| 18 |
return PDF_PATH
|
| 19 |
|
| 20 |
|
| 21 |
def export_docx(text: str) -> str:
|
| 22 |
-
|
| 23 |
for line in text.split("\n"):
|
| 24 |
-
|
| 25 |
-
|
| 26 |
return DOCX_PATH
|
|
|
|
| 9 |
def export_pdf(text: str) -> str:
|
| 10 |
styles = getSampleStyleSheet()
|
| 11 |
doc = SimpleDocTemplate(PDF_PATH)
|
| 12 |
+
content = [Paragraph(line or " ", styles["Normal"]) for line in text.split("\n")]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
doc.build(content)
|
| 14 |
return PDF_PATH
|
| 15 |
|
| 16 |
|
| 17 |
def export_docx(text: str) -> str:
|
| 18 |
+
doc = Document()
|
| 19 |
for line in text.split("\n"):
|
| 20 |
+
doc.add_paragraph(line)
|
| 21 |
+
doc.save(DOCX_PATH)
|
| 22 |
return DOCX_PATH
|