Make point wise notes from the given sources
From this
python3 -c " import pdfplumber with pdfplumber.open('/home/daytona/workspace/attachments/3e5ae69d-ffe4-4fdc-ab02-a7a2e1ec2327/split_3706508907379180178.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): text = page.extract_text() print(f'--- PAGE {i+1} ---') print(text) print() "
python3 -c " import subprocess result = subprocess.run(['which', 'tesseract'], capture_output=True, text=True) print('tesseract:', result.stdout.strip()) result2 = subprocess.run(['which', 'pdftoppm'], capture_output=True, text=True) print('pdftoppm:', result2.stdout.strip()) result3 = subprocess.run(['python3', '-c', 'import pytesseract; print(pytesseract.__version__)'], capture_output=True, text=True) print('pytesseract:', result3.stdout.strip(), result3.stderr.strip()) "
mkdir -p /home/daytona/workspace/ocr_pages && pdftoppm -r 200 /home/daytona/workspace/attachments/3e5ae69d-ffe4-4fdc-ab02-a7a2e1ec2327/split_3706508907379180178.pdf /home/daytona/workspace/ocr_pages/page && ls /home/daytona/workspace/ocr_pages/ | head -20
python3 -c " import pytesseract from PIL import Image import os, glob pages_dir = '/home/daytona/workspace/ocr_pages' files = sorted(glob.glob(f'{pages_dir}/page-*.ppm')) all_text = [] for f in files: img = Image.open(f) text = pytesseract.image_to_string(img) page_num = os.path.basename(f).replace('page-','').replace('.ppm','') all_text.append(f'=== PAGE {page_num} ===\n{text}\n') full_text = '\n'.join(all_text) with open('/home/daytona/workspace/ocr_output.txt', 'w') as out: out.write(full_text) print('Done. Total chars:', len(full_text)) " 2>&1
python3 -c " import pytesseract from PIL import Image # Test just first page img = Image.open('/home/daytona/workspace/ocr_pages/page-01.ppm') text = pytesseract.image_to_string(img) print(repr(text[:500])) " 2>&1
python3 << 'EOF' import pytesseract from PIL import Image import glob, os pages_dir = '/home/daytona/workspace/ocr_pages' files = sorted(glob.glob(f'{pages_dir}/page-*.ppm')) all_text = [] # Process pages 1-10 for f in files[:10]: img = Image.open(f) text = pytesseract.image_to_string(img) page_num = os.path.basename(f).replace('page-','').replace('.ppm','') all_text.append(f'=== PAGE {page_num} ===\n{text}\n') with open('/home/daytona/workspace/ocr_batch1.txt', 'w') as out: out.write('\n'.join(all_text)) print('Batch 1 done') EOF
python3 << 'EOF' import pytesseract from PIL import Image import glob, os pages_dir = '/home/daytona/workspace/ocr_pages' files = sorted(glob.glob(f'{pages_dir}/page-*.ppm')) all_text = [] for f in files[10:21]: img = Image.open(f) text = pytesseract.image_to_string(img) page_num = os.path.basename(f).replace('page-','').replace('.ppm','') all_text.append(f'=== PAGE {page_num} ===\n{text}\n') with open('/home/daytona/workspace/ocr_batch2.txt', 'w') as out: out.write('\n'.join(all_text)) print('Batch 2 done') EOF