kpal002 commited on
Commit
6ba811c
·
verified ·
1 Parent(s): ac5cfb1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -97,23 +97,31 @@ def generate_score_bar(score, num_criteria):
97
  return score_bar_html
98
 
99
  class PDF(FPDF):
 
 
 
 
 
 
 
100
  def header(self):
101
- self.set_font('Arial', 'B', 12)
102
  self.cell(0, 10, 'Paper Analysis Report', 0, 1, 'C')
103
 
104
  def footer(self):
105
  self.set_y(-15)
106
- self.set_font('Arial', 'I', 8)
107
  self.cell(0, 10, f'Page {self.page_no()}', 0, 0, 'C')
108
 
109
  def create_pdf_report(title, author_info, score, reasoning_html, output_path):
110
  pdf = PDF()
111
  pdf.add_page()
112
- pdf.set_font("Arial", size=12)
113
  pdf.cell(0, 10, f"Title: {title}", 0, 1)
114
  pdf.cell(0, 10, f"Author Information: {author_info}", 0, 1)
115
  pdf.cell(0, 10, f"Score: {score}", 0, 1)
116
- pdf.multi_cell(0, 10, f"Reasoning: \n{reasoning_html}")
 
117
  pdf.output(output_path)
118
 
119
 
 
97
  return score_bar_html
98
 
99
  class PDF(FPDF):
100
+ def __init__(self, *args, **kwargs):
101
+ super().__init__(*args, **kwargs)
102
+ # Assuming the Roboto font files have been converted and added to your project directory
103
+ self.add_font('Roboto', '', 'Roboto/Roboto-Regular.ttf', uni=True)
104
+ self.add_font('Roboto', 'B', 'Roboto/Roboto-Bold.ttf', uni=True)
105
+ self.add_font('Roboto', 'I', 'Roboto/Roboto-Italic.ttf', uni=True)
106
+
107
  def header(self):
108
+ self.set_font('Roboto', '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('Roboto', '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_html, output_path):
117
  pdf = PDF()
118
  pdf.add_page()
119
+ pdf.set_font("Roboto", size=12)
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)
123
+ reasoning_text = remove_html_tags(reasoning_html) # Make sure to handle HTML if present
124
+ pdf.multi_cell(0, 10, f"Reasoning: \n{reasoning_text}")
125
  pdf.output(output_path)
126
 
127