Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -99,24 +99,25 @@ def generate_score_bar(score, num_criteria):
|
|
99 |
class PDF(FPDF):
|
100 |
def __init__(self, *args, **kwargs):
|
101 |
super().__init__(*args, **kwargs)
|
102 |
-
#
|
103 |
-
self.add_font('
|
104 |
-
self.add_font('
|
105 |
-
self.add_font('
|
106 |
|
107 |
def header(self):
|
108 |
-
self.set_font('
|
109 |
self.cell(0, 10, 'Paper Analysis Report', 0, 1, 'C')
|
110 |
|
111 |
def footer(self):
|
112 |
self.set_y(-15)
|
113 |
-
self.set_font('
|
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 |
pdf.cell(0, 10, f"Title: {title}", 0, 1)
|
121 |
pdf.cell(0, 10, f"Author Information: {author_info}", 0, 1)
|
122 |
pdf.cell(0, 10, f"Score: {score}", 0, 1)
|
|
|
99 |
class PDF(FPDF):
|
100 |
def __init__(self, *args, **kwargs):
|
101 |
super().__init__(*args, **kwargs)
|
102 |
+
# Load the DejaVu font files
|
103 |
+
self.add_font('DejaVu', '', 'DejaVu_Sans/DejaVuSansCondensed.ttf', uni=True)
|
104 |
+
self.add_font('DejaVu', 'B', 'DejaVu_Sans/DejaVuSansCondensed-Bold.ttf', uni=True)
|
105 |
+
self.add_font('DejaVu', 'I', 'DejaVu_Sans/DejaVuSansCondensed-Oblique.ttf', uni=True)
|
106 |
|
107 |
def header(self):
|
108 |
+
self.set_font('DejaVu', 'B', 12)
|
109 |
self.cell(0, 10, 'Paper Analysis Report', 0, 1, 'C')
|
110 |
|
111 |
def footer(self):
|
112 |
self.set_y(-15)
|
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 |
+
# Set the font to DejaVu for Unicode support
|
120 |
+
pdf.set_font("DejaVu", size=12)
|
121 |
pdf.cell(0, 10, f"Title: {title}", 0, 1)
|
122 |
pdf.cell(0, 10, f"Author Information: {author_info}", 0, 1)
|
123 |
pdf.cell(0, 10, f"Score: {score}", 0, 1)
|