downloads cedarville publishing books as pdf
at main 86 lines 2.7 kB view raw
1#!/bin/bash 2set -e 3 4echo "================================================" 5echo "Cedarville Cybersecurity Textbook PDF Creator" 6echo "================================================" 7echo "" 8 9# Colors for output 10GREEN='\033[0;32m' 11BLUE='\033[0;34m' 12NC='\033[0m' # No Color 13 14# Get the directory where this script is located 15SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 16cd "$SCRIPT_DIR" 17 18# Step 1: Setup virtual environment 19echo -e "${BLUE}[Step 1/6] Setting up Python virtual environment...${NC}" 20if [ ! -d "venv" ]; then 21 python3 -m venv venv 22 echo "✓ Virtual environment created" 23else 24 echo "✓ Virtual environment already exists" 25fi 26 27source venv/bin/activate 28 29# Step 2: Install Python dependencies 30echo -e "${BLUE}[Step 2/6] Installing Python dependencies...${NC}" 31pip install -q --upgrade pip 32pip install -q -r requirements.txt 33echo "✓ Python packages installed" 34 35# Step 3: Install Playwright browsers 36echo -e "${BLUE}[Step 3/6] Installing Playwright browsers...${NC}" 37if [ ! -d "$HOME/.cache/ms-playwright" ]; then 38 python -m playwright install chromium 39 echo "✓ Playwright browser installed" 40else 41 echo "✓ Playwright browser already installed" 42fi 43 44# Step 4: Download page layers (SVG + WebP) 45echo -e "${BLUE}[Step 4/6] Downloading page layers...${NC}" 46if [ ! -d "svg_layers" ] || [ ! -d "webp_highres" ]; then 47 echo "This will download 340 pages (SVG + high-res WebP)" 48 echo "Estimated time: 10-15 minutes" 49 echo "" 50 python download_layers.py 51 echo -e "${GREEN}✓ All page layers downloaded${NC}" 52else 53 echo "✓ Page layers already downloaded" 54fi 55 56# Step 5: Create PDF 57echo -e "${BLUE}[Step 5/5] Creating PDF with vector text...${NC}" 58if [ ! -f "Invitation_to_Cybersecurity.pdf" ]; then 59 echo "This will create PDF with embedded vector text" 60 echo "Estimated time: 30-60 seconds" 61 echo "" 62 python create_pdf.py 63 echo -e "${GREEN}✓ PDF created with selectable text!${NC}" 64else 65 echo "✓ PDF already exists" 66 read -p "Recreate PDF? (y/N): " recreate 67 if [[ $recreate =~ ^[Yy]$ ]]; then 68 rm Invitation_to_Cybersecurity.pdf 69 python create_pdf.py 70 echo -e "${GREEN}✓ PDF recreated${NC}" 71 fi 72fi 73 74echo "" 75echo -e "${GREEN}================================================${NC}" 76echo -e "${GREEN}✓ Complete!${NC}" 77echo -e "${GREEN}================================================${NC}" 78echo "" 79echo "Output files:" 80if [ -f "Invitation_to_Cybersecurity.pdf" ]; then 81 SIZE=$(du -h "Invitation_to_Cybersecurity.pdf" | cut -f1) 82 echo " 📄 Invitation_to_Cybersecurity.pdf ($SIZE) [vector text + high-res images]" 83fi 84echo "" 85echo "✨ Text is embedded as vectors - selectable and searchable!" 86echo ""