#!/usr/bin/env bash # Render an HTML brief to PDF via headless Chrome (uses system fonts → Korean OK). # Part of ourdigital-presales-seo (Stage 6). # Usage: render_pdf.sh [output.pdf] set -euo pipefail HTML="${1:?usage: render_pdf.sh [output.pdf]}" OUT="${2:-${HTML%.html}.pdf}" CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" if [ ! -x "$CHROME" ]; then CHROME="/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"; fi if [ ! -x "$CHROME" ]; then CHROME="/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"; fi if [ ! -x "$CHROME" ]; then echo "ERROR: no Chromium-based browser found for PDF rendering" >&2; exit 1; fi DIR="$(cd "$(dirname "$HTML")" && pwd)" BASE="$(basename "$HTML")" "$CHROME" --headless --disable-gpu --no-pdf-header-footer \ --print-to-pdf="$OUT" "file://$DIR/$BASE" 2>/dev/null echo "Wrote $OUT"