import gradio as gr from pdf2docx import Converter import os import tempfile def convert_pdf_to_word(pdf_file): if pdf_file is None: return None # Create a temporary file to store the converted Word document with tempfile.NamedTemporaryFile(delete=False, suffix=".docx") as tmp_file: word_file = tmp_file.name # Create converter object and perform conversion cv = Converter(pdf_file.name) cv.convert(word_file) cv.close() return word_file # Create Gradio interface iface = gr.Interface( fn=convert_pdf_to_word, inputs=gr.File(label="Upload PDF File", type="filepath",file_types=["pdf"]), outputs=gr.File(label="Download Word File"), title="PDF to Word Converter", description="""

Converting PDF to Word is a common office task, and this application allows you to convert PDF to Word documents with just one click.

Upload a PDF file and download the converted Word document.

For more PDF tools, visit: pdf-tools.wingetgui.com

""", allow_flagging="never", analytics_enabled=False ) # Launch Gradio app iface.launch()