Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -112,17 +112,25 @@ def merge_duplicates(entries):
|
|
| 112 |
seen_titles.append(entry['title'])
|
| 113 |
return unique
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
def generate_pdf(text):
|
| 116 |
-
pdf =
|
| 117 |
-
pdf.
|
| 118 |
-
|
| 119 |
-
pdf.
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
pdf_output = BytesIO()
|
| 123 |
-
pdf.output(pdf_output)
|
| 124 |
-
pdf_output.seek(0)
|
| 125 |
-
return pdf_output
|
| 126 |
|
| 127 |
def generate_latex(text):
|
| 128 |
latex = "\\documentclass{article}\n\\usepackage{hyperref}\n\\begin{document}\n"
|
|
|
|
| 112 |
seen_titles.append(entry['title'])
|
| 113 |
return unique
|
| 114 |
|
| 115 |
+
|
| 116 |
+
class PDF(FPDF):
|
| 117 |
+
def __init__(self):
|
| 118 |
+
super().__init__()
|
| 119 |
+
self.set_auto_page_break(auto=True, margin=15)
|
| 120 |
+
self.add_page()
|
| 121 |
+
self.set_font("Arial", size=12)
|
| 122 |
+
|
| 123 |
+
def add_multiline_text(self, text):
|
| 124 |
+
for line in text.split('\n'):
|
| 125 |
+
self.multi_cell(0, 10, line)
|
| 126 |
+
|
| 127 |
def generate_pdf(text):
|
| 128 |
+
pdf = PDF()
|
| 129 |
+
pdf.add_multiline_text(text.encode('latin-1', 'replace').decode('latin-1'))
|
| 130 |
+
output = BytesIO()
|
| 131 |
+
pdf.output(output)
|
| 132 |
+
output.seek(0)
|
| 133 |
+
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
|
| 135 |
def generate_latex(text):
|
| 136 |
latex = "\\documentclass{article}\n\\usepackage{hyperref}\n\\begin{document}\n"
|