#!/usr/bin/env python3 import sys import os # Add the virtual environment to the path sys.path.insert(0, '/home/rpm/claude/ryanmalloy.com/static-files/documents/pdf_env/lib/python3.12/site-packages') import fitz # PyMuPDF def fix_resume_dates(input_path, output_path): """Fix both date issues in the resume properly.""" # Open the clean backup PDF doc = fitz.open(input_path) print(f"PDF has {len(doc)} pages") changes_made = 0 # Process each page for page_num in range(len(doc)): page = doc.load_page(page_num) print(f"Processing page {page_num + 1}") # Fix 1: Change Intouch Solutions from "02/2001 - 11/2002" to "05/2002 - 11/2003" intouch_instances = page.search_for("02/2001 - 11/2002") if intouch_instances: for inst in intouch_instances: print(f"Fixing Intouch Solutions dates at: {inst}") # Add a redaction annotation to remove the old text redact_annot = page.add_redact_annot(inst) page.apply_redactions() # Insert the corrected text insertion_point = fitz.Point(inst.x0, (inst.y0 + inst.y1) / 2) page.insert_text( insertion_point, "05/2002 - 11/2003", fontsize=9, color=(0, 0, 0) ) changes_made += 1 # Fix 2: Change Joint School District from "01/2001 - 2/2002" to "01/2001 - 5/2002" district_instances = page.search_for("01/2001 - 2/2002") if district_instances: for inst in district_instances: print(f"Fixing Joint School District dates at: {inst}") # Add a redaction annotation to remove the old text redact_annot = page.add_redact_annot(inst) page.apply_redactions() # Insert the corrected text insertion_point = fitz.Point(inst.x0, (inst.y0 + inst.y1) / 2) page.insert_text( insertion_point, "01/2001 - 5/2002", fontsize=9, color=(0, 0, 0) ) changes_made += 1 print(f"Made {changes_made} date corrections") if changes_made == 0: print("No target text found. Current text in PDF:") for page_num in range(len(doc)): page = doc.load_page(page_num) text = page.get_text() if "Intouch Solutions" in text: lines = text.split('\n') for i, line in enumerate(lines): if "Intouch Solutions" in line: start = max(0, i-1) end = min(len(lines), i+3) for j in range(start, end): prefix = ">>> " if j == i else " " print(f"{prefix}{lines[j]}") # Save the modified PDF doc.save(output_path) doc.close() print(f"Clean resume saved to: {output_path}") if __name__ == "__main__": fix_resume_dates("Ryan_Malloy_Resume_backup.pdf", "Ryan_Malloy_Resume_clean_fixed.pdf")