Markdown Print: One-Command PDF Rendering and Printing from the Terminal

Two Claude Code skills that convert local Markdown files to A4 PDFs and send them to a Brother laser printer, all from a single voice command.

The Problem

Printing a Markdown file shouldn't require opening a browser, pasting into Google Docs, adjusting margins, and hitting Ctrl+P. But that's what most people do. In a household where printed lesson plans, checklists, and reference sheets are part of the daily routine, that friction adds up.

We needed: say "print this file" and have paper come out of the printer. No intermediate steps.

What the Skills Do

The project includes two nearly identical skills — markdown-print and print-markdown — that handle Markdown-to-printer conversion. They exist as separate entry points for natural language flexibility (some people say "print this markdown" and others say "send this to the printer"), but they share the same pipeline:

  1. Validate the file. Expand ~ paths, confirm the file exists.
  2. Add PDF front-matter. If the Markdown file doesn't already have YAML front-matter with PDF options, prepend a standard block: A4 format, 20mm margins on all sides, print background enabled.
  3. Convert to PDF. Run npx md-to-pdf, which uses headless Chromium (Puppeteer) to render the Markdown as a styled PDF with GitHub-style syntax highlighting for code blocks.
  4. Send to printer. Use lp to send the PDF to the Brother HL-L2360D with A4 media and fit-to-page options.
  5. Report the print job ID.

Options

Natural language modifiers adjust the output:

  • "print 2 copies" → adds -n 2 to the lp command
  • "duplex" or "double-sided" → adds -o sides=two-sided-long-edge
  • "landscape" → sets landscape: true in the front-matter and passes -o landscape to lp
  • "no margins" → reduces all margins to 5mm for near-full-bleed output
  • "just save the PDF" → skips the print step entirely, useful for review before committing to paper

Implementation Notes

A few things learned the hard way:

  • Never modify the original file. The skill always writes a temporary copy to /tmp/ before adding front-matter, so your source Markdown is never touched.
  • First run is slow. The first npx md-to-pdf invocation downloads Chromium (~170 MB). Subsequent runs are fast.
  • Relative image paths break. If your Markdown references images with relative paths and you copy it to /tmp/, those paths won't resolve. The skill passes --basedir pointing to the original file's directory when needed.
  • Long documents just work. CSS @page rules handle pagination automatically — no manual page breaks needed.

Role in the Ecosystem

These skills are the final step in several pipelines. The daily-lesson-plans skill produces Markdown; notion-printable-markdown produces Markdown; both feed into markdown-print for the last mile to paper. They also work standalone for any local .md file you want printed.