Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,23 @@ from fpdf import FPDF
|
|
| 4 |
from docx import Document
|
| 5 |
import os
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
def pdf_to_word(pdf_file):
|
| 8 |
docx_filename = pdf_file.name.replace('.pdf', '.docx')
|
| 9 |
|
|
@@ -30,20 +47,22 @@ def word_to_pdf(docx_file):
|
|
| 30 |
return pdf_filename
|
| 31 |
|
| 32 |
with gr.Blocks() as app:
|
|
|
|
|
|
|
| 33 |
with gr.Row():
|
| 34 |
with gr.Column():
|
| 35 |
-
with gr.Accordion("PDF
|
| 36 |
-
pdf_input = gr.File(label="
|
| 37 |
-
convert_pdf_to_word = gr.Button("
|
| 38 |
-
word_output = gr.File(label="
|
| 39 |
|
| 40 |
convert_pdf_to_word.click(pdf_to_word, inputs=[pdf_input], outputs=[word_output])
|
| 41 |
|
| 42 |
with gr.Column():
|
| 43 |
-
with gr.Accordion("Word
|
| 44 |
-
word_input = gr.File(label="
|
| 45 |
-
convert_word_to_pdf = gr.Button("
|
| 46 |
-
pdf_output = gr.File(label="
|
| 47 |
|
| 48 |
convert_word_to_pdf.click(word_to_pdf, inputs=[word_input], outputs=[pdf_output])
|
| 49 |
|
|
|
|
| 4 |
from docx import Document
|
| 5 |
import os
|
| 6 |
|
| 7 |
+
|
| 8 |
+
title_and_description = """
|
| 9 |
+
# PDF to Word and Word to PDF converter
|
| 10 |
+
Created by [@artificialguybr](https://artificialguy.com)
|
| 11 |
+
|
| 12 |
+
Upload a PDF file to convert to Word or a Word file to convert to PDF.
|
| 13 |
+
|
| 14 |
+
## Features
|
| 15 |
+
- **Easy to use**: Simple interface to upload PDF or Word files and convert to the desired format.
|
| 16 |
+
- **High quality**: Converts while maintaining the best possible quality.
|
| 17 |
+
- **Efficient processing**: Uses `pdf2docx`, `fpdf` and `docx` for fast and reliable conversions.
|
| 18 |
+
- **Unlimited Use**: No file limit. Use unlimited!
|
| 19 |
+
|
| 20 |
+
Feel free to use in your own documents!
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
|
| 24 |
def pdf_to_word(pdf_file):
|
| 25 |
docx_filename = pdf_file.name.replace('.pdf', '.docx')
|
| 26 |
|
|
|
|
| 47 |
return pdf_filename
|
| 48 |
|
| 49 |
with gr.Blocks() as app:
|
| 50 |
+
gr.Markdown(title_and_description)
|
| 51 |
+
|
| 52 |
with gr.Row():
|
| 53 |
with gr.Column():
|
| 54 |
+
with gr.Accordion("PDF para Word"):
|
| 55 |
+
pdf_input = gr.File(label="Carregar PDF")
|
| 56 |
+
convert_pdf_to_word = gr.Button("Converter para Word")
|
| 57 |
+
word_output = gr.File(label="Baixar arquivo Word", type="filepath")
|
| 58 |
|
| 59 |
convert_pdf_to_word.click(pdf_to_word, inputs=[pdf_input], outputs=[word_output])
|
| 60 |
|
| 61 |
with gr.Column():
|
| 62 |
+
with gr.Accordion("Word para PDF"):
|
| 63 |
+
word_input = gr.File(label="Carregar Word")
|
| 64 |
+
convert_word_to_pdf = gr.Button("Converter para PDF")
|
| 65 |
+
pdf_output = gr.File(label="Baixar arquivo PDF", type="filepath")
|
| 66 |
|
| 67 |
convert_word_to_pdf.click(word_to_pdf, inputs=[word_input], outputs=[pdf_output])
|
| 68 |
|