hr-assistance / pdf_to_txt.py
renceabishek's picture
more changes
72fbd66
raw
history blame contribute delete
656 Bytes
import pdfplumber
def extract_text_from_pdf(pdf_path):
text = ""
with pdfplumber.open(pdf_path) as pdf:
for page in pdf.pages:
page_text = page.extract_text()
if page_text:
text += page_text + "\n"
return text
def save_text_to_file(text, output_path):
with open(output_path, "w", encoding="utf-8") as f:
f.write(text)
# === Usage ===
pdf_path = "resume.pdf" # Your input PDF
output_path = "resume.txt" # Output text file
resume_text = extract_text_from_pdf(pdf_path)
save_text_to_file(resume_text, output_path)
print(f"✅ Extracted text saved to {output_path}")