Spaces:
Sleeping
Sleeping
File size: 692 Bytes
919f74f 8b0be64 f3515e2 8b0be64 b2971fd 8b0be64 0f6f41c 8b0be64 f3515e2 8b0be64 f3515e2 8b0be64 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import gradio as gr
import PyMuPDF as fitz # Importing PyMuPDF as fitz
# Function to extract text from a PDF
def extract_pdf_text(file):
doc = fitz.open(file.name) # Open the PDF file using PyMuPDF
text = ""
for page in doc:
text += page.get_text() # Extract text from each page
return text
# Gradio interface
output_format_dropdown = gr.Dropdown(
choices=["txt", "pdf", "docx"],
label="Output Format",
default="txt"
)
iface = gr.Interface(
fn=extract_pdf_text,
inputs=gr.File(label="Upload PDF File"),
outputs=[gr.Textbox(label="Extracted Text"), output_format_dropdown],
live=True
)
if __name__ == "__main__":
iface.launch()
|