Cristobal299 commited on
Commit
7b36df3
·
verified ·
1 Parent(s): ab16899

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ import os
3
+ import fitz # PyMuPDF
4
+ import gradio as gr
5
+ from gradio_theme_fenix import apply_fenix_theme, FENIX_CSS, fenix_header, fenix_footer
6
+
7
+ def extract_text(pdf_path):
8
+ """Extract text from a PDF file located at pdf_path."""
9
+ doc = fitz.open(pdf_path)
10
+ text = ""
11
+ for page in doc:
12
+ text += page.get_text()
13
+ doc.close()
14
+ return text
15
+
16
+ with gr.Blocks(css=FENIX_CSS, theme=apply_fenix_theme(), title="PDF Reader") as demo:
17
+ fenix_header("PDF Reader", "Extract text from PDF files")
18
+ with gr.Row():
19
+ pdf_input = gr.File(label="Upload PDF", type="filepath")
20
+ extract_btn = gr.Button("Extract")
21
+ output_box = gr.Textbox(label="Extracted Text", lines=20, interactive=False)
22
+ extract_btn.click(fn=extract_text, inputs=pdf_input, outputs=output_box)
23
+ fenix_footer()
24
+
25
+ demo.launch()