Spaces:
Sleeping
Sleeping
File size: 647 Bytes
da2c28a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# genesis/utils/pdf_export.py
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
import os
def export_to_pdf(content: str, filename: str = "output.pdf"):
"""Export given text content to a PDF file."""
filepath = os.path.join(os.getcwd(), filename)
doc = SimpleDocTemplate(filepath, pagesize=letter)
styles = getSampleStyleSheet()
story = []
for line in content.split("\n"):
story.append(Paragraph(line, styles["Normal"]))
story.append(Spacer(1, 12))
doc.build(story)
return filepath
|