Rammohan0504 commited on
Commit
7f44100
·
verified ·
1 Parent(s): 6b0a154

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +15 -0
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