Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,13 +33,21 @@ def word_to_pdf(docx_file):
|
|
33 |
|
34 |
doc = Document(docx_file)
|
35 |
pdf = FPDF()
|
|
|
|
|
|
|
|
|
|
|
36 |
pdf.add_page()
|
37 |
-
pdf.set_font("Helvetica", size=12)
|
38 |
|
39 |
for para in doc.paragraphs:
|
40 |
-
# Split the paragraph into lines
|
41 |
lines = para.text.split('\n')
|
42 |
for line in lines:
|
|
|
|
|
|
|
|
|
|
|
43 |
pdf.multi_cell(0, 10, line)
|
44 |
|
45 |
pdf.output(pdf_filename)
|
|
|
33 |
|
34 |
doc = Document(docx_file)
|
35 |
pdf = FPDF()
|
36 |
+
|
37 |
+
# Add Arial font
|
38 |
+
pdf.add_font('Arial', '', 'Arial.ttf', uni=True)
|
39 |
+
pdf.set_font('Arial', size=12)
|
40 |
+
|
41 |
pdf.add_page()
|
|
|
42 |
|
43 |
for para in doc.paragraphs:
|
|
|
44 |
lines = para.text.split('\n')
|
45 |
for line in lines:
|
46 |
+
# Check if the line is too long and adjust
|
47 |
+
if len(line) > 90: # Adjust this number based on your needs
|
48 |
+
pdf.set_font('Arial', size=10) # Adjust font size
|
49 |
+
else:
|
50 |
+
pdf.set_font('Arial', size=12)
|
51 |
pdf.multi_cell(0, 10, line)
|
52 |
|
53 |
pdf.output(pdf_filename)
|