Download app.py from Tanseer45203/Slide_Generation_Conversion_App: direct link, hf CLI and curl.
- Browser
- Download file 853 Bytes
-
https://huggingface.co/spaces/Tanseer45203/Slide_Generation_Conversion_App/resolve/main/app.py
- Command line
-
hf download hf://spaces/Tanseer45203/Slide_Generation_Conversion_App/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Tanseer45203/Slide_Generation_Conversion_App/resolve/main/app.py
853 Bytes
| # Function to create a PDF | |
| def create_pdf(slide_contents): | |
| pdf = FPDF() | |
| pdf.set_auto_page_break(auto=True, margin=15) | |
| pdf.set_font("Arial", style="", size=12) | |
| for slide_content in slide_contents: | |
| pdf.add_page() | |
| title, *points = slide_content.split("\n") | |
| # Encode title properly | |
| title = title.encode("latin-1", "ignore").decode("latin-1") | |
| pdf.set_font("Arial", style="B", size=16) | |
| pdf.cell(0, 10, title, ln=True, align="C") | |
| pdf.set_font("Arial", style="", size=12) | |
| for point in points: | |
| # Replace unsupported characters before writing to PDF | |
| point = point.replace("•", "-").encode("latin-1", "ignore").decode("latin-1") | |
| pdf.multi_cell(0, 10, f"- {point}") | |
| pdf_io = BytesIO() | |
| pdf.output(pdf_io, "F") | |
| return pdf_iotopic.") |