How to print Markdown or save it as a PDF on a Mac

To turn Markdown into a PDF on a Mac, open it formatted, then use the Mac's own Save as PDF. Open the .md file in an app that renders Markdown, press ⌘P, click PDF at the bottom left of the print dialog, name the file and click Save. Printing a .md file from TextEdit gives you the raw text, marks and all.

Steps: save a Markdown file as a PDF with Pagewide

  1. Open the .md file in Pagewide.
  2. Choose File › Print…, or press ⌘P.
  3. In the print dialog, click PDF at the bottom left, or open the menu next to it and choose Save as PDF.
  4. Name the PDF, choose where to save it, and click Save.

To print on paper instead, pick your printer in the same dialog and click Print.

What a printed Markdown page looks like from Pagewide

Pagewide prints for paper, not for the screen:

In split view, Print acts on the side you clicked last.

Other ways to make a PDF from Markdown

Any app that shows Markdown formatted can use the same Save as PDF step. A few other routes suit other jobs:

RouteGood forKeep in mind
An editor's preview, then PrintOccasional PDFs while you writeSome previews print the editor's colours or cut wide tables
pandoc, from TerminalMany files, scripts, styled reportsPDF output needs a PDF engine, such as a LaTeX installation
An editor's export menuWriting apps with built-in export, such as TyporaThe look depends on that app's themes

With pandoc installed, the simplest command is:

pandoc notes.md -o notes.pdf

Questions

Why does my PDF show # and ** marks?

The file was printed as plain text, usually from TextEdit. Open it in an app that renders Markdown first, then print or save as PDF from there.

Can I keep links clickable in the PDF?

Save as PDF from a rendered page normally keeps web links clickable. Check the result in Preview, because some apps flatten links when printing.

How do I make the PDF smaller or larger on the page?

Use the Scale setting in the print dialog. In Pagewide you can also change the theme before printing, because the printed page uses the theme's fonts.

References

  1. Apple, Save a document as a PDF on Mac.
  2. pandoc, User's Guide.

Related: wide Markdown tables, and themes and custom CSS for the look of the printed page.