Files
claude-config/presentation/build-pdf.sh
T

26 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Print index.html to loop-claude-explained.pdf beside it, in the playwright-for-claude image.
# The image comes from ~/code/playwright-for-agents: its ./pw builds it on first use.
set -eu
here=$(cd "$(dirname "$0")" && pwd)
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
if ! docker image inspect playwright-for-claude >/dev/null 2>&1; then
echo "No playwright-for-claude image. Build it once with: ~/code/playwright-for-agents/pw about:blank" >&2
exit 1
fi
# index.html is an artifact body, without a doctype, head or body of its own, so wrap it as the artifact host does.
{
printf '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><style>:root{color-scheme:light}body{margin:0}img{max-width:100%%}[hidden]{display:none!important}</style></head><body>\n'
cat "$here/index.html"
printf '</body></html>\n'
} > "$work/page.html"
cp "$here/render-pdf.js" "$work/"
docker run --rm --init --memory 2g --memory-swap 2g -v "$work:/work" -w /work --entrypoint node playwright-for-claude render-pdf.js
cp "$work/out.pdf" "$here/loop-claude-explained.pdf"
echo "Wrote $here/loop-claude-explained.pdf"