# Setup and Extract PDFs # This script installs dependencies and extracts PDF text Write-Host "=== PDF Extraction Setup ===" -ForegroundColor Cyan Write-Host "" # Check if Python is available Write-Host "Checking for Python..." -ForegroundColor Yellow $pythonAvailable = $false try { $pythonVersion = python --version 2>&1 if ($pythonVersion -match "Python") { Write-Host " Found: $pythonVersion" -ForegroundColor Green $pythonAvailable = $true } } catch { Write-Host " Python not found" -ForegroundColor Red } # If Python available, install PyPDF2 if ($pythonAvailable) { Write-Host "" Write-Host "Installing PyPDF2..." -ForegroundColor Yellow try { python -m pip install PyPDF2 --quiet Write-Host " PyPDF2 installed successfully" -ForegroundColor Green } catch { Write-Host " Warning: Could not install PyPDF2" -ForegroundColor Yellow } } # Alternative: Download iTextSharp via NuGet Write-Host "" Write-Host "Checking for NuGet..." -ForegroundColor Yellow $nugetPath = "C:\DEV\COPILOT\nuget.exe" if (-not (Test-Path $nugetPath)) { Write-Host " Downloading NuGet.exe..." -ForegroundColor Yellow try { Invoke-WebRequest -Uri "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $nugetPath Write-Host " NuGet downloaded successfully" -ForegroundColor Green } catch { Write-Host " Warning: Could not download NuGet" -ForegroundColor Yellow } } if (Test-Path $nugetPath) { Write-Host " Installing iTextSharp..." -ForegroundColor Yellow try { & $nugetPath install iTextSharp -Version 5.5.13.3 -OutputDirectory "C:\DEV\COPILOT\packages" Write-Host " iTextSharp installed successfully" -ForegroundColor Green } catch { Write-Host " Warning: Could not install iTextSharp" -ForegroundColor Yellow } } Write-Host "" Write-Host "=== Running PDF Extraction ===" -ForegroundColor Cyan Write-Host "" # Run the extraction script & "C:\DEV\COPILOT\extract_pdfs.ps1"