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
- Open the .md file in Pagewide.
- Choose File › Print…, or press ⌘P.
- In the print dialog, click PDF at the bottom left, or open the menu next to it and choose Save as PDF.
- 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:
- Dark text on white, in the fonts of your current theme, even if you read in a dark theme.
- Tables wrap their cells, so they stay within the page. Table rows are not split across pages, and a long table repeats its header row on each page.
- Headings stay with their text, so a heading never sits alone at the bottom of a page.
- Smart References print as plain text, without link styling or previews.
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:
| Route | Good for | Keep in mind |
|---|---|---|
| An editor's preview, then Print | Occasional PDFs while you write | Some previews print the editor's colours or cut wide tables |
| pandoc, from Terminal | Many files, scripts, styled reports | PDF output needs a PDF engine, such as a LaTeX installation |
| An editor's export menu | Writing apps with built-in export, such as Typora | The 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
- Apple, Save a document as a PDF on Mac.
- pandoc, User's Guide.
Related: wide Markdown tables, and themes and custom CSS for the look of the printed page.