Update app.py
Browse files
app.py
CHANGED
@@ -531,27 +531,31 @@ def generate_documentation_page():
|
|
531 |
|
532 |
|
533 |
# Helper function to generate PDF
|
534 |
-
def generate_pdf(documentation,
|
535 |
pdf = FPDF()
|
536 |
pdf.set_auto_page_break(auto=True, margin=15)
|
537 |
pdf.add_page()
|
538 |
-
pdf.set_font("Courier", size=12)
|
539 |
|
540 |
# Add headers and content
|
541 |
for line in documentation.splitlines():
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
|
|
|
|
|
|
552 |
|
553 |
# Save the PDF
|
554 |
-
pdf.output(
|
|
|
555 |
|
556 |
|
557 |
|
|
|
531 |
|
532 |
|
533 |
# Helper function to generate PDF
|
534 |
+
def generate_pdf(documentation, pdf_path):
|
535 |
pdf = FPDF()
|
536 |
pdf.set_auto_page_break(auto=True, margin=15)
|
537 |
pdf.add_page()
|
538 |
+
pdf.set_font("Courier", size=12) # Maintain the IDE-like font style
|
539 |
|
540 |
# Add headers and content
|
541 |
for line in documentation.splitlines():
|
542 |
+
try:
|
543 |
+
if line.startswith("- '"):
|
544 |
+
pdf.set_font("Courier", style="B", size=12) # Bold for specific lines
|
545 |
+
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
546 |
+
elif line.startswith("Project Summary:") or line.startswith("Functionality Summary:") or \
|
547 |
+
line.startswith("Functionality Flow:") or line.startswith("Function Documentation:"):
|
548 |
+
pdf.set_font("Courier", style="B", size=14) # Bold larger headers
|
549 |
+
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
550 |
+
else:
|
551 |
+
pdf.set_font("Courier", size=12) # Regular for other lines
|
552 |
+
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
553 |
+
except UnicodeEncodeError as e:
|
554 |
+
pdf.multi_cell(0, 10, line.encode('latin-1', 'replace').decode('latin-1'))
|
555 |
|
556 |
# Save the PDF
|
557 |
+
pdf.output(pdf_path)
|
558 |
+
|
559 |
|
560 |
|
561 |
|