simikkk commited on
Commit
cc739fc
·
verified ·
1 Parent(s): 5768ba4

Create pdf_parser.py

Browse files
Files changed (1) hide show
  1. pdf_parser.py +11 -0
pdf_parser.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pdfplumber
2
+
3
+ def extract_text_from_pdf(file_path: str) -> str:
4
+ if file_path is None:
5
+ return ""
6
+ try:
7
+ with pdfplumber.open(file_path) as pdf:
8
+ pages = [page.extract_text() or "" for page in pdf.pages]
9
+ return "\n".join(pages).strip()
10
+ except Exception as e:
11
+ return f"Chyba při čtení PDF: {str(e)}"