markdown-to-pdf
Skill0 starsChanged 16 days agoApache-2.0View on GitHub
Use when asked to turn a Markdown file into a PDF, export a .md report for printing or sharing, or produce a printable deliverable from Markdown, especially documents containing mermaid diagrams, wide tables, or that need page numbers and a running header.
12 other projects use a version of this.
Adopted by
Most recently taken up by
- staskh/trading_skillstheir own version, first seen Nov 8, 2026
- ong6/skillstheir own version, first seen Nov 5, 2026
- matthull/my-skillstheir own version, first seen Oct 20, 2026
- guishiw/Guishi-Skillstheir own version, first seen Oct 20, 2026
- rahulrajaram/rahulskillstheir own version, first seen Oct 13, 2026
- shitcoding/claude_skillstheir own version, first seen Oct 11, 2026
Other versions12 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 12
- staskh/trading_skills★ 411same name
- black-yt/skills★ 16same name
- guishiw/Guishi-Skills★ 8same name
- leotrinh/ai-agent-skills★ 3same name
- quickcall-dev/skills★ 2same name
- bendyworks/claude-skills★ 1same name
- dzivkovi/claude-skills★ 1same name
- THEROCKSSS/hermes-skills-portfolio★ 1same name
- matthull/my-skills★ 0same name
- ong6/skills★ 0same name
2 more not listed
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 repository2 other files it gives its agents.
- ec2-ml-trainingSkill
- ts-ml-lookahead-auditSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 9 edited versions we read keep these.
1
Distinctive
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
- Very specific: line 30
Use the path where the skill is installed if it is not under ~/.claude/skills.
- Distinctive: line 66
Check: no diagram clipped at a page edge, no table or code block running off the right margin, no page of pure whitespace (a blank page …
“Common” is measured: kept by at least 6 in 10 of the 9 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Markdown to PDF
Overview
Renders a Markdown file to a print-quality PDF via headless Chromium. Mermaid
diagrams come out as vector SVG, tables repeat their header row across page
breaks, and every page gets a running header and Page N of M footer.
Oversized diagrams are the hard part, and the script handles them: a diagram taller than the page is sliced across consecutive pages, and one far wider than the page is wrapped into stacked left-to-right bands. Both keep labels readable instead of shrinking the figure into an unreadable sliver.
Rendering is local. The page runs under a Content Security Policy that lets only the renderer's own scripts run and blocks every external fetch, and the browser aborts any request that gets past it. Scripts, event handlers and remote resources in raw HTML are blocked and listed on stderr.
Usage
node ~/.claude/skills/markdown-to-pdf/md2pdf.js <input.md> [output.pdf] [options]Use the path where the skill is installed if it is not under ~/.claude/skills.
Output defaults to the input path with .pdf substituted. Options:
| Option | Effect |
--note "TEXT" | Right-hand running-header text (e.g. a status or confidentiality caveat) |
--format Letter|A4 | Paper size (default Letter) |
--landscape | Landscape orientation |
The document title (browser tab, PDF metadata, left-hand running header) comes
from the first # heading, falling back to the filename.
Mermaid diagrams are fenced code blocks with the info string mermaid, with
backticks or tildes. Markdown images with a local path are read relative to the
Markdown file and embedded. A missing local image, or an image with an http
or https URL, stops the render with an error: download remote images first.
The script prints a line per oversized diagram saying how it was handled, and a
blocked line per script or resource the page was not allowed to run or load.
Relay anything still flagged as too small, and any blocked line, to the user.
First run installs markdown-it, mermaid, and playwright-core into the skill
directory automatically. Chromium is found in this order: CHROME_PATH, the
build pinned by playwright-core at Playwright's install path, the newest build
in the Playwright cache, then system Chrome/Chromium.
After rendering, always verify
The command exits non-zero if a diagram fails, but it cannot see layout problems. Render pages to images and look at them:
pdftoppm -png -r 75 out.pdf /tmp/preview/p # then Read the PNGsCheck: no diagram clipped at a page edge, no table or code block running off the right margin, no page of pure whitespace (a blank page means content was clipped, not merely pushed). Report the page count to the user.
Design notes (why it is built this way)
Each of these fixes a bug that is invisible until you look at rendered pages:
- Chrome clips; it does not slice or scroll. Anything overflowing the print
margin box is silently cut: an SVG taller than the page loses its lower half,
a long code line loses its right end. Hence
white-space: pre-wraponpre, and the diagram slicing/banding rather than plain scaling. - Page margins are 6 mm;
<main>is padded 10 mm. Body text keeps a readable measure while.mermaid-slotuses negative margins to reach nearly the full sheet. A diagram cannot be given more room by breaking out past the margins, because that region is clipped, so the margins themselves have to be narrow. - Mermaid's inline
width/max-widthare stripped after render. Mermaid writes them on the<svg>, where they outrank the stylesheet and let wide flowcharts run off the page. The script removes them and scales via the viewBox. - The viewport is set to the printed diagram width so mermaid measures label wrapping at the width the diagram will occupy in print.
- Slices and bands overlap (36 px / 110 px) so a node cut by a seam reappears whole on the adjacent slice.
thead { display: table-header-group }repeats table headers on continuation pages;tr { break-inside: avoid }stops rows splitting mid-cell.
Common problems
| Symptom | Cause / fix |
| Diagram cut off at a page edge | Inline SVG sizing survived, or margins were widened. See design notes. |
| Blank page containing only a faint box | A diagram overflowed and was clipped; the slicing threshold did not trigger. |
| Diagram still flagged too small | Dense and neither tall nor wide enough to band. It is vector, so it zooms; for print, try --landscape or ask whether the diagram can be split at the source. |
| Large blank gap before a diagram | A diagram that will not fit is pushed whole to the next page. Expected. |
| Source file changed mid-build | stat the .md against the .pdf afterwards; rerun if it moved. |
Styling
report.css holds the print stylesheet: serif body, sans headings and tables,
navy accent, banded rows, callout styling for blockquotes. Edit it to restyle;
it applies to every document rendered by this skill.
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
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.

