agentleFS
crywolfecrywolfe/claude-code-design/.claude/skills/export-pdf/SKILL.md

export-pdf

Skill0 starsChanged 7 days agoMITView on GitHub

Export an HTML artifact to PDF via headless Chromium (puppeteer Page.pdf). For multi-slide decks one page per <section>.

  • Installs packages

2 other projects use a version of this, 1 of them edited.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the output directory does not exist: Bash(mkdir -p <output-dir>) with the literal directory (no command substitution — the bash guard …

    line 24

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Export PDF

Produce a PDF from an HTML artifact. Uses puppeteer's Page.pdf() which is lossless vector when the source is HTML/CSS/SVG.

Why puppeteer instead of Chrome DevTools MCP: the MCP does not expose Page.printToPDF directly (only take_screenshot, list_console_messages, evaluate_script, etc.). Using puppeteer via a Node script is deterministic and matches /export-pptx.

Preflight

  1. Bash(node --version) — required (which node is blocked by the guard)
  2. Bash(ls -d node_modules/puppeteer) — if it prints No such file or directory, tell the user to run npm install -D puppeteer@24.41.0 in a separate shell (or /doctor for the full list), and stop. Do not use test -d here: it prints nothing on failure and the exit code is not visible in the tool result, so a missing install reads as a pass and the script then dies on import puppeteer with a bare Node stack trace

Steps

  1. Resolve paths:
    • $0 = input HTML (required)
    • $1 = output (default: input with .pdf extension)
    • If the output directory does not exist: Bash(mkdir -p <output-dir>) with the literal directory (no command substitution — the bash guard rejects $(...))
  2. Run export script:
    Bash(node scripts/export-pdf.mjs "<input>" "<output>")
    (The script is versioned at scripts/export-pdf.mjs. If it is missing, restore it from git — do not rewrite it, and never run node with anything other than that script.)
  3. Report size + path.

Script behaviour (scripts/export-pdf.mjs)

  • Launches headless Chromium without --no-sandbox (only added when CI is set)
  • Blocks every outbound request except the artifact's own directory over file://, data:, blob:, https://unpkg.com/ and Google Fonts. A deck that loads ../starters/deck_stage.js instead of a copy beside the HTML therefore exports with the stage script blocked: the sections never become slides and the PDF is one page of stacked content. test/smoke-deck.html is such a file and is not an export target; real decks get the starter copied next to them by make-deck; DNS for every other host is disabled (--host-resolver-rules, which also covers WebSockets) and popups are closed — an artifact cannot phone home during export. A copy from artifacts/publish/ (rewritten to jsdelivr) will not export; export the source artifact instead
  • Decks render one <section> per page at natural size; other pages default to A4

Notes

  • For decks: deck_stage.js must have @media print { @page { size: ... } section { page-break-after: always } } in the global <style> it injects — already present.
  • For general pages: defaults to A4. To override, user can pass inline CSS @page { size: letter } or similar.
  • networkidle0 waits for all network activity to stop — if artifact uses lazy images, bump timeout to 15000ms.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.