Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,29 +31,21 @@ def pdf_to_word(pdf_file):
|
|
| 31 |
return docx_filename
|
| 32 |
|
| 33 |
def word_to_pdf(docx_file):
|
| 34 |
-
pdf_filename =
|
| 35 |
-
|
| 36 |
-
document = Document(docx_file
|
| 37 |
pdf = FPDF()
|
| 38 |
|
| 39 |
-
# Add Arial font
|
| 40 |
-
pdf.add_font('Arial', '', 'Arial.ttf', uni=True)
|
| 41 |
-
|
| 42 |
pdf.add_page()
|
| 43 |
-
pdf.set_font(
|
| 44 |
-
pdf.set_auto_page_break(auto=True, margin=15)
|
| 45 |
|
| 46 |
for paragraph in document.paragraphs:
|
| 47 |
-
|
| 48 |
-
pdf.multi_cell(0, 10, paragraph.text)
|
| 49 |
-
except Exception as e:
|
| 50 |
-
print(f"Error processing paragraph: {e}")
|
| 51 |
|
| 52 |
pdf.output(pdf_filename)
|
| 53 |
|
| 54 |
return pdf_filename
|
| 55 |
|
| 56 |
-
|
| 57 |
with gr.Blocks() as app:
|
| 58 |
gr.Markdown(title_and_description)
|
| 59 |
|
|
|
|
| 31 |
return docx_filename
|
| 32 |
|
| 33 |
def word_to_pdf(docx_file):
|
| 34 |
+
pdf_filename = "output.pdf"
|
| 35 |
+
|
| 36 |
+
document = Document(docx_file)
|
| 37 |
pdf = FPDF()
|
| 38 |
|
|
|
|
|
|
|
|
|
|
| 39 |
pdf.add_page()
|
| 40 |
+
pdf.set_font("Helvetica", size=12) # Usando Helvetica como fonte padrão
|
|
|
|
| 41 |
|
| 42 |
for paragraph in document.paragraphs:
|
| 43 |
+
pdf.multi_cell(0, 10, paragraph.text)
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
pdf.output(pdf_filename)
|
| 46 |
|
| 47 |
return pdf_filename
|
| 48 |
|
|
|
|
| 49 |
with gr.Blocks() as app:
|
| 50 |
gr.Markdown(title_and_description)
|
| 51 |
|