randomshit11 commited on
Commit
b51440d
·
verified ·
1 Parent(s): e3fabe4

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import PyPDF2
3
+
4
+ def extract_text_from_pdf(pdf_file_path):
5
+ text = ""
6
+ with open(pdf_file_path, "rb") as f:
7
+ reader = PyPDF2.PdfFileReader(f)
8
+ num_pages = reader.numPages
9
+ for page_num in range(num_pages):
10
+ page = reader.getPage(page_num)
11
+ text += page.extractText()
12
+ return text
13
+
14
+ def main():
15
+ st.title("PDF Text Extractor")
16
+
17
+ st.write("Yahan PDF file ko upload kare:")
18
+
19
+ uploaded_file = st.file_uploader("Select PDF file", type=['pdf'])
20
+
21
+ if uploaded_file is not None:
22
+ st.write("PDF file ka naam:", uploaded_file.name)
23
+ st.write("File ka size:", uploaded_file.size)
24
+
25
+ if st.button("Extract Text"):
26
+ text = extract_text_from_pdf(uploaded_file)
27
+ st.write("Extracted Text:")
28
+ st.write(text)
29
+
30
+ if __name__ == "__main__":
31
+ main()