-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathextractor.py
More file actions
29 lines (24 loc) · 789 Bytes
/
Copy pathextractor.py
File metadata and controls
29 lines (24 loc) · 789 Bytes
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
29
import pymupdf
from docx import Document
def extract_text_from_pdf(pdf_path):
extracted_text = ""
try:
with pymupdf.open(pdf_path) as file:
for page in file:
extracted_text += page.get_text()
except Exception as e:
print(f"Error extracting PDF: {e}")
return extracted_text
def extract_text_from_docx(docx_path):
extracted_text = ""
try:
document = Document(docx_path)
for paragraph in document.paragraphs:
extracted_text += paragraph.text + "\n"
except Exception as e:
print(f"Error extracting DOCX: {e}")
return extracted_text
pdf_text = extract_text_from_pdf("resume-sample.pdf")
docx_text = extract_text_from_docx("resume-sample.docx")
print(pdf_text)
print(docx_text)