DEV Community

Cover image for From Markdown to PDF
Ana Cunha
Ana Cunha

Posted on

From Markdown to PDF

Today I wanted to print a markdown file and found out there was no straightforward way to do it from my code editor. Even though they have beautiful markdown previews, they won't let you print them.

That's when I found pandoc. Pandoc is a document converter that can turn markdown into PDF. It does this by converting markdown to LaTeX first, then using LaTeX to generate the PDF.

I don't miss struggling with LaTeX from my computer science student days, but it always produced beautiful documents (when I didn't mess anything up).

Here is the setup on macOS:

brew install pandoc
brew install basictex
Enter fullscreen mode Exit fullscreen mode

After installing basictex, restart your terminal to get the LaTeX binaries in your path.

Then:

pandoc file.md -o file.pdf
Enter fullscreen mode Exit fullscreen mode

That's it. PDFs from all your Markdown files.

Top comments (1)

Collapse
 
fromchiapasdev profile image
Axel Espinosa

Obsidian can export your documents to PDF. I think you should try it!! πŸ™ŒπŸ»πŸ™ŒπŸ»πŸ™ŒπŸ»πŸ™ŒπŸ»πŸ™ŒπŸ»