JSenkCC commited on
Commit
2c5ad6d
·
verified ·
1 Parent(s): 775d3a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -531,27 +531,31 @@ def generate_documentation_page():
531
 
532
 
533
  # Helper function to generate PDF
534
- def generate_pdf(documentation, output_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)
539
 
540
  # Add headers and content
541
  for line in documentation.splitlines():
542
- if line.startswith("- '"):
543
- pdf.set_font("Courier", style="B", size=12) # Bold for specific lines
544
- pdf.multi_cell(0, 10, line)
545
- elif line.startswith("Project Summary:") or line.startswith("Functionality Summary:") or \
546
- line.startswith("Functionality Flow:") or line.startswith("Function Documentation:"):
547
- pdf.set_font("Courier", style="B", size=14) # Bold larger headers
548
- pdf.multi_cell(0, 10, line)
549
- else:
550
- pdf.set_font("Courier", size=12) # Regular for other lines
551
- pdf.multi_cell(0, 10, line)
 
 
 
552
 
553
  # Save the PDF
554
- pdf.output(output_path)
 
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