File size: 710 Bytes
fc5e5f2
3117482
 
eb44df9
3117482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from PyPDF2 import PdfReader
import os

def process_pdf(file):
    # Read the PDF content
    pdf_reader = PdfReader(file.name)
    text = ""
    for page in pdf_reader.pages:
        text += page.extract_text()
    return text
    
  with gr.Blocks() as demo:
    gr.Markdown("### File upload", elem_classes="tab-header")
    with gr.Row():
    text_output = gr.Textbox(label="text")
        file_input = gr.File(label="Wähle eine PDF-Datei aus", type="filepath")
        upload_output = gr.Textbox(label="Upload Status")
    with gr.Row():
        submit_button = gr.Button("upload")
    submit_button.click(process_pdf, inputs=file_input, outputs=text_output 
    
    demo.launch())