ATSScanner / convert.py
bainskarman's picture
Update convert.py
4e28c13 verified
raw
history blame contribute delete
578 Bytes
import pdfplumber
import streamlit as st
from io import BytesIO # Import BytesIO
def ExtractPDFText(pdf):
content = ""
pdf_bytes = pdf.read()
try:
# Using pdfplumber to read the PDF bytes
with pdfplumber.open(BytesIO(pdf_bytes)) as pdf_document:
# Iterate through pages and extract text
for page in pdf_document.pages:
text = page.extract_text()
content += text if text else ""
except Exception as e:
st.error(f"Error extracting text from PDF: {e}")
return content