Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -21,6 +21,11 @@ def download_image(image_url):
|
|
21 |
return local_image_path
|
22 |
|
23 |
class PDF(FPDF):
|
|
|
|
|
|
|
|
|
|
|
24 |
def chapter_title(self, num, label):
|
25 |
self.set_font('Arial', 'B', 12)
|
26 |
self.cell(0, 10, f"Chapter {num} : {label}", 0, 1, 'C')
|
@@ -41,7 +46,7 @@ class PDF(FPDF):
|
|
41 |
def save_as_pdf():
|
42 |
global chapters
|
43 |
pdf_path = "/mnt/data/chapters.pdf"
|
44 |
-
pdf = PDF()
|
45 |
for i, chapter in enumerate(chapters, start=1):
|
46 |
pdf.add_chapter(i, f"Chapter {i}", chapter["story"], chapter["image"])
|
47 |
pdf.output(pdf_path)
|
|
|
21 |
return local_image_path
|
22 |
|
23 |
class PDF(FPDF):
|
24 |
+
def __init__(self, *args, **kwargs):
|
25 |
+
super().__init__(*args, **kwargs)
|
26 |
+
self.set_auto_page_break(auto=True, margin=15)
|
27 |
+
self.add_font('DejaVu', '', '/usr/share/fonts/truetype/dejavu/DejaVuSansCondensed.ttf', uni=True)
|
28 |
+
|
29 |
def chapter_title(self, num, label):
|
30 |
self.set_font('Arial', 'B', 12)
|
31 |
self.cell(0, 10, f"Chapter {num} : {label}", 0, 1, 'C')
|
|
|
46 |
def save_as_pdf():
|
47 |
global chapters
|
48 |
pdf_path = "/mnt/data/chapters.pdf"
|
49 |
+
pdf = PDF(encoding='UTF-8')
|
50 |
for i, chapter in enumerate(chapters, start=1):
|
51 |
pdf.add_chapter(i, f"Chapter {i}", chapter["story"], chapter["image"])
|
52 |
pdf.output(pdf_path)
|