markdown-to-pdflisted
Install: claude install-skill kennethkhoocy/applied-micro-skills
# Markdown → PDF (pandoc + headless Chrome)
## Problem
Converting Markdown to PDF through pandoc's default LaTeX route breaks on
real-world GitHub-flavored documents: Unicode box-drawing characters in code
blocks (`├──`) crash pdflatex, wide GFM tables overflow the page, remote
images need manual download, and the output looks nothing like the rendered
Markdown the author reviewed. Naive HTML routes drop images or paste them at
native resolution so they spill off the page.
## Context / Trigger Conditions
- User asks to save/convert/export a `.md` file as PDF.
- The document carries images (hosted PNGs, local figures), GFM tables,
fenced code blocks, blockquotes, or `#`-anchor TOC links.
- Requirements like "all images must be preserved" or "scaled appropriately".
## Solution
Render the Markdown to HTML exactly as a browser would, then print it.
**One command (preferred):**
```
python ~/.claude/skills/markdown-to-pdf/scripts/md2pdf.py <input.md> [-o out.pdf]
```
The script: (1) runs pandoc `-f gfm -t html5 --standalone --embed-resources`
with `assets/print.css`, executed from the Markdown's own directory so
relative image paths resolve, and with remote images fetched and inlined as
data URIs; (2) prints with headless Chrome (Edge/Chromium fallback) using
`--no-pdf-header-footer --virtual-time-budget=30000`; (3) verifies with pypdf
that the embedded raster-image count is at least the number of image
references in the source, printing each image's page and dimensions.