Skip to content

Instantly share code, notes, and snippets.

@justincbagley
Last active September 3, 2026 03:28
Show Gist options
  • Select an option

  • Save justincbagley/ec0a6334cc86e854715e459349ab1446 to your computer and use it in GitHub Desktop.

Select an option

Save justincbagley/ec0a6334cc86e854715e459349ab1446 to your computer and use it in GitHub Desktop.
How To Convert Markdown to PDF

How to convert markdown to PDF:

This post reviews several methods for converting a Markdown (.md) formatted file to PDF, from UNIX or Linux machines.

Using Pandoc:

$ pandoc How_I_got_svg-resizer_working_on_Mac_OSX.md -s -o test1.pdf

Other methods:

GRIP

http://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdf I've had success using grip to display markdown in Chrome and then use Chrome's "Save as PDF" option in the Print dialog.

pip install grip  
grip your_markdown.md

grip will render the markdown on localhost:5000 ... - just edit away and refresh the browser. Print when ready.

This gave a more reliable representation than pandoc and was lighter weight than installing LaTeX (required by pandoc for pdf generation).

The print is not command line in this answer, but still found this easier/more reliable (looked 100% like Github for a long document including relatively linked images and code highlighting).

Node.js

http://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdf You can also use Node.js based markdown-pdf

npm install -g markdown-pdf
markdown-pdf /path/to/markdown

NOTES:

The GRIP results look just like GitHub README pages. The Pandoc result looks like (is) LaTex format. And the Node.js result is the most original looking, but slightly harder to read than GRIP output PDF. Overall, I prefer GRIP output.

@usmankhan045

Copy link
Copy Markdown

Late to this thread but wanted to add a browser-based option for anyone
who lands here not wanting to install anything.

mdtool.dev/markdown-to-pdf runs entirely client-side, so nothing gets
uploaded to a server. Supports GFM, fenced code blocks with syntax
highlighting (190+ languages via highlight.js), tables, images, and
Mermaid diagrams. Four themes to choose from. No signup, no watermark,
no file size limit.

Useful if you just need a quick conversion without setting up Pandoc or
dealing with the highlight.js EOL issue in older node packages.

@mluffie

mluffie commented Aug 7, 2026

Copy link
Copy Markdown

convertmdtopdf.com seems to be watermark free and has support for themes. Live preview also matches the final export. I no longer have issues with asian fonts.

@tsilvs

tsilvs commented Aug 24, 2026

Copy link
Copy Markdown

I'd recommend rendering MD to HTML and then printing from a browser. Probably can be automater with JS.

@noobM3

noobM3 commented Aug 26, 2026

Copy link
Copy Markdown

Pandoc remains one of the most reliable options for converting Markdown documentation into clean PDFs, particularly when automating technical guides or exports for web projects like https://tiktokstoryviewer.com/. Pairing it with a solid PDF engine gives much better control over styling, code blocks, and layout compared to basic browser printing. Thank you for compiling these command-line methods in one place.

@noobM3

noobM3 commented Sep 3, 2026

Copy link
Copy Markdown

The breakdown between Pandoc and GRIP is very helpful—relying on GRIP and browser printing avoids massive LaTeX dependencies while preserving GitHub-style rendering. This approach works great when archiving Markdown documentation or technical notes containing web citations. If your notes reference social posts or updates where chronological accuracy matters, a tool like https://linkedinpostdateextractor.com/ is handy for finding the exact post publication time before generating the final PDF report. Thanks for sharing these alternatives!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment