Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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,
|
117 |
pdf = PDF()
|
118 |
pdf.add_page()
|
119 |
|
120 |
-
#
|
121 |
-
|
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',
|
128 |
-
|
129 |
-
pdf.
|
|
|
130 |
|
131 |
# Author Information
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
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',
|
141 |
-
pdf.
|
|
|
|
|
142 |
|
143 |
# Reasoning
|
144 |
-
pdf.set_font("DejaVu", 'B',
|
145 |
-
|
146 |
-
|
147 |
-
|
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)
|