Spaces:
Sleeping
Sleeping
Create utils.py
Browse files
utils.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fpdf import FPDF
|
2 |
+
import io
|
3 |
+
|
4 |
+
def create_pdf(captions: list):
|
5 |
+
pdf = FPDF()
|
6 |
+
pdf.add_page()
|
7 |
+
pdf.set_font("Arial", size=12)
|
8 |
+
|
9 |
+
for i, text in enumerate(captions):
|
10 |
+
pdf.multi_cell(0, 10, f"{text}\n")
|
11 |
+
|
12 |
+
buffer = io.BytesIO()
|
13 |
+
pdf.output(buffer)
|
14 |
+
buffer.seek(0)
|
15 |
+
return buffer
|