agentleFS
ryanramtinryanramtin/claude-skills/skills/artifact-to-pdf/SKILL.md

artifact-to-pdf

Skill1 starsChanged 2 months agoMITView on GitHub

Save a Claude Artifact (or any HTML file) as a PDF with faithful CSS/layout. Use when the user wants to export, download, convert, or "save as PDF" an artifact, an HTML page, or a claude.ai/code/artifact URL, or asks the cleanest way to turn HTML into a PDF.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. yheshamx/artifact-to-pdf★ 4same name
    2. davidgrahamsites/Claude-Skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository7 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Verify success: first 8 bytes are %PDF-1.4 and file size is non-trivial.

    line 44
  2. Distinctive:

    When you only have the artifact URL, drive the user's logged-in Chrome (browser tools), then convert.

    line 48
  3. Very specific:

    If none is installed, weasyprint file.html out.pdf or wkhtmltopdf file.html out.pdf work but render some modern CSS less faithfully than …

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

Artifact → PDF

Convert a Claude Artifact or standalone HTML file to a PDF that preserves the original CSS/layout, by rendering through Chrome's own engine.

First: is the HTML already on disk?

The whole task hinges on getting the artifact's HTML onto the filesystem. Ask/check before doing anything else.

  • User has the .html file (or pastes the HTML) → go straight to Convert.
  • Only a claude.ai/code/artifact/… URL → the content is login-gated and loads client-side, so curl returns only the SPA shell and headless Chrome can't authenticate. Get the HTML first via Get HTML from a login-gated artifact.

Quick start (recommend this to a person)

The cleanest path for a human needs no tools:

Open the artifact → Cmd+P (Print) → Destination: Save as PDF → Save.

It uses the browser's own renderer, so layout is exact. Only reach for the scripted path below when the user wants it hands-free/automated, or when you must produce the PDF.

Convert (HTML on disk → PDF)

One headless-Chrome command, no dialog. Use the bundled script:

~/.claude/skills/artifact-to-pdf/scripts/html2pdf.sh "/path/to/artifact.html" "/path/to/out.pdf"

Or inline:

"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
  --headless --disable-gpu --no-pdf-header-footer \
  --print-to-pdf="out.pdf" "file:///abs/path/to/artifact.html"

Notes:

  • file:// needs an absolute path; spaces in the path are fine when quoted.
  • --no-pdf-header-footer removes the URL/date margins. Drop it if the user wants them.
  • Verify success: first 8 bytes are %PDF-1.4 and file size is non-trivial.

Get HTML from a login-gated artifact

When you only have the artifact URL, drive the user's logged-in Chrome (browser tools), then convert. Steps:

  1. tabs_context_mcp{createIfEmpty:true}, then navigate the tab to the artifact URL.
  2. The artifact renders in a cross-origin iframe (<uuid>.frame.claudeusercontent.com) — you can't read it same-origin, and its src carries an auth token. Instead, navigate the tab itself to the frame URL so the artifact becomes the top document:
    window.location.href = document.querySelector('iframe').src; 'navigating';
    (After this, location.pathname is /code/frame/<uuid> — still under claude.ai, now same-origin and readable.)
  3. Trigger a download of the rendered HTML from inside the page (the base64/text channel back through the browser tool is blocked, so a Blob download is the reliable move):
    const h = '<!doctype html>\n' + document.documentElement.outerHTML;
    const a = document.createElement('a');
    a.href = URL.createObjectURL(new Blob([h], {type:'text/html'}));
    a.download = 'artifact.html';
    document.body.appendChild(a); a.click(); a.remove();
  4. The download may need the user's confirmation. Find the saved file (~/Downloads or ~/Desktop), then run Convert on it.

Simplest alternative to steps 2–4: tell the user to use the artifact's own ⋯ menu → Download as HTML, then hand you the file.

Non-Mac / no Chrome

  • Chrome/Chromium/Brave all accept the same --headless --print-to-pdf flags (swap the binary path).
  • If none is installed, weasyprint file.html out.pdf or wkhtmltopdf file.html out.pdf work but render some modern CSS less faithfully than Chrome.

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.