sundeep-news-scan/scratch_py/_search_pdf.py

14 lines
374 B
Python

import fitz
import sys
from pathlib import Path
# Find the PDF in the processed directory
pdf_path = next(Path("processed").glob("Jyothi_SiddipetDistrict_17-05-2026*.pdf"))
doc = fitz.open(str(pdf_path))
if len(doc) >= 4:
page = doc[3] # 0-indexed page 4 is index 3
print("PAGE 4 TEXT:")
print(page.get_text())
else:
print(f"PDF only has {len(doc)} pages")