kpal002 commited on
Commit
038f9aa
·
verified ·
1 Parent(s): f9585ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -24
app.py CHANGED
@@ -113,41 +113,37 @@ class PDF(FPDF):
113
  self.set_font('DejaVu', 'I', 8)
114
  self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
115
 
116
- def create_pdf_report(title, author_info, score, reasoning, output_path):
117
  pdf = PDF()
118
  pdf.add_page()
119
 
120
- # Define a larger font size for the title, author information, and score
121
- large_font_size = 14
122
-
123
- # Define a smaller font size for the reasoning as it might be longer
124
- small_font_size = 12
125
 
126
  # Title
127
- pdf.set_font("DejaVu", 'B', large_font_size) # Use bold style and large font size
128
- # If title is a single string, no need for join
129
- pdf.multi_cell(0, 10, f"Title:\n{title}", 0, 1)
 
130
 
131
  # Author Information
132
- # If author_info is a list, join it, otherwise just print the string
133
- if isinstance(author_info, list):
134
- author_info_text = "\n".join([f"{idx + 1}. {info}" for idx, info in enumerate(author_info)])
135
- else:
136
- author_info_text = author_info
137
- pdf.multi_cell(0, 10, f"Author Information:\n{author_info_text}", 0, 1)
138
 
139
  # Score
140
- pdf.set_font("DejaVu", 'B', large_font_size) # Use bold style and large font size
141
- pdf.multi_cell(0, 10, f"Score:\n{score}", 0, 1)
 
 
142
 
143
  # Reasoning
144
- pdf.set_font("DejaVu", 'B', small_font_size) # Use bold style and smaller font size
145
- # If reasoning is a list, join it, otherwise just print the string
146
- if isinstance(reasoning, list):
147
- reasoning_text = "\n".join([f"{idx + 1}. {reason}" for idx, reason in enumerate(reasoning)])
148
- else:
149
- reasoning_text = reasoning
150
- pdf.multi_cell(0, 10, f"Reasoning:\n{reasoning_text}", 0, 1)
151
 
152
  # Save the PDF to the specified output path
153
  pdf.output(output_path)
 
113
  self.set_font('DejaVu', 'I', 8)
114
  self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
115
 
116
+ def create_pdf_report(title, author_info, score, reasoning_text, output_path):
117
  pdf = PDF()
118
  pdf.add_page()
119
 
120
+ # Set margins
121
+ pdf.set_left_margin(10)
122
+ pdf.set_right_margin(10)
 
 
123
 
124
  # Title
125
+ pdf.set_font("DejaVu", 'B', 14) # Bold and larger font for the heading
126
+ pdf.cell(0, 10, "Title:", 0, 1)
127
+ pdf.set_font("DejaVu", '', 12) # Regular and smaller font for the content
128
+ pdf.multi_cell(0, 10, title, 0, 1)
129
 
130
  # Author Information
131
+ pdf.set_font("DejaVu", 'B', 14) # Bold and larger font for the heading
132
+ pdf.cell(0, 10, "Author Information:", 0, 1)
133
+ pdf.set_font("DejaVu", '', 12) # Regular and smaller font for the content
134
+ pdf.multi_cell(0, 10, author_info, 0, 1)
 
 
135
 
136
  # Score
137
+ pdf.set_font("DejaVu", 'B', 14) # Bold and larger font for the heading
138
+ pdf.cell(0, 10, "Score:", 0, 1)
139
+ pdf.set_font("DejaVu", '', 12) # Regular and smaller font for the content
140
+ pdf.multi_cell(0, 10, score, 0, 1)
141
 
142
  # Reasoning
143
+ pdf.set_font("DejaVu", 'B', 14) # Bold and larger font for the heading
144
+ pdf.cell(0, 10, "Reasoning:", 0, 1)
145
+ pdf.set_font("DejaVu", '', 12) # Regular and smaller font for the content
146
+ pdf.multi_cell(0, 10, reasoning_text, 0, 1)
 
 
 
147
 
148
  # Save the PDF to the specified output path
149
  pdf.output(output_path)