← ClaudeAtlas

markdown-to-pdflisted

Convert Markdown (.md) files to a polished PDF with ALL images preserved and scaled to the page. Use whenever the user asks to "save this markdown as a PDF", "convert README.md to pdf", "export the .md as a pdf", "turn these notes/docs into a PDF", or wants a PDF deliverable of any GitHub-flavored Markdown document (README, design doc, report, notes) — especially when it contains images or diagrams (remote or local), tables, code blocks, or a linked table of contents. Pipeline: pandoc (GFM → standalone HTML with embedded resources) → headless Chrome print-to-pdf with a GitHub-like print stylesheet → pypdf verification that every referenced image is embedded. Do NOT use for .tex → PDF (use a LaTeX toolchain) or for .docx work (use word-docx / tex2docx).
kennethkhoocy/applied-micro-skills · ★ 1 · Data & Documents · score 77
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.