#!/bin/bash set -e echo "================================================" echo "Cedarville Cybersecurity Textbook PDF Creator" echo "================================================" echo "" # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Get the directory where this script is located SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd "$SCRIPT_DIR" # Step 1: Setup virtual environment echo -e "${BLUE}[Step 1/6] Setting up Python virtual environment...${NC}" if [ ! -d "venv" ]; then python3 -m venv venv echo "✓ Virtual environment created" else echo "✓ Virtual environment already exists" fi source venv/bin/activate # Step 2: Install Python dependencies echo -e "${BLUE}[Step 2/6] Installing Python dependencies...${NC}" pip install -q --upgrade pip pip install -q -r requirements.txt echo "✓ Python packages installed" # Step 3: Install Playwright browsers echo -e "${BLUE}[Step 3/6] Installing Playwright browsers...${NC}" if [ ! -d "$HOME/.cache/ms-playwright" ]; then python -m playwright install chromium echo "✓ Playwright browser installed" else echo "✓ Playwright browser already installed" fi # Step 4: Download page layers (SVG + WebP) echo -e "${BLUE}[Step 4/6] Downloading page layers...${NC}" if [ ! -d "svg_layers" ] || [ ! -d "webp_highres" ]; then echo "This will download 340 pages (SVG + high-res WebP)" echo "Estimated time: 10-15 minutes" echo "" python download_layers.py echo -e "${GREEN}✓ All page layers downloaded${NC}" else echo "✓ Page layers already downloaded" fi # Step 5: Create PDF echo -e "${BLUE}[Step 5/5] Creating PDF with vector text...${NC}" if [ ! -f "Invitation_to_Cybersecurity.pdf" ]; then echo "This will create PDF with embedded vector text" echo "Estimated time: 30-60 seconds" echo "" python create_pdf.py echo -e "${GREEN}✓ PDF created with selectable text!${NC}" else echo "✓ PDF already exists" read -p "Recreate PDF? (y/N): " recreate if [[ $recreate =~ ^[Yy]$ ]]; then rm Invitation_to_Cybersecurity.pdf python create_pdf.py echo -e "${GREEN}✓ PDF recreated${NC}" fi fi echo "" echo -e "${GREEN}================================================${NC}" echo -e "${GREEN}✓ Complete!${NC}" echo -e "${GREEN}================================================${NC}" echo "" echo "Output files:" if [ -f "Invitation_to_Cybersecurity.pdf" ]; then SIZE=$(du -h "Invitation_to_Cybersecurity.pdf" | cut -f1) echo " 📄 Invitation_to_Cybersecurity.pdf ($SIZE) [vector text + high-res images]" fi echo "" echo "✨ Text is embedded as vectors - selectable and searchable!" echo ""