RoutePlannerApp / pdf_parser.py
ArielKes's picture
add geolocation verification levels
f358592
Raw
History Blame Contribute Delete
693 Bytes
import pdfplumber
from bidi.algorithm import get_display
def extract_text_from_pdf(data_path):
"""Extract text from a PDF using pdfplumber."""
pdfplumber_text = []
with pdfplumber.open(data_path) as pdf:
for page in pdf.pages:
pdfplumber_text.append(page.extract_text())
return "\n".join(pdfplumber_text)
def fix_hebrew_lines(text):
"""Reverse lines that contain Hebrew characters (for RTL display)."""
return get_display(text)
def process_pdf_hebrew_rtl(data_path):
"""Full pipeline: extract from PDF and fix RTL issues."""
raw_text = extract_text_from_pdf(data_path)
fixed_text = fix_hebrew_lines(raw_text)
return fixed_text