Open your Markdown in the editor, click Print, and set the destination to Save as PDF. What gets printed is the preview pane, so the PDF looks like a finished document. You get real headings, styled tables and proper code blocks instead of raw text full of asterisks.

This works because every modern browser has a PDF engine inside its print dialog. Nothing is installed, and nothing is uploaded.

Page numbers, cross-references and a hundred documents built by a script are a different job. That is where Pandoc takes over, and the comparison further down weighs the two honestly.

At a glance

Methods availableBrowser print dialog, Pandoc, editor extensions
Best print fidelityPandoc with a LaTeX engine
Install neededNone for the browser route
Links preservedYes, still clickable in the saved PDF
Page breaksAutomatic, nudge them with content or CSS

Four routes compared

All four produce a real PDF. They differ in what you have to install, and in how much typographic control you get back.

RouteInstallTypographyBest for
Editor Print buttonNoneGood, browser stylesOne document, immediately
Pandoc with LaTeXLarge downloadBook quality, auto page numbersReports, theses, print
Pandoc with weasyprintPython packageStyled by your own CSSWeb teams, branded output
VS Code extensionEditor add-onVaries by extensionExporting while you write

When the browser route is enough

For most people the browser is not a compromise. It costs nothing, takes ten seconds, and gives you a document that matches the preview. It also works on a locked-down work laptop where you cannot install anything. If you would rather start from a page built for this one job, the Markdown to PDF tool puts the same preview and print button on one screen.

When to move to Pandoc

  • You need an automatic page number on every page.
  • You need a generated table of contents, or running headers and footers.
  • The same command has to run unattended every Monday morning.

A print routine that gives a clean result

  1. Start the document with a single # title, so the PDF opens with a clear name.
  2. Read the preview once and use heading levels in order, because that structure is all a printed page has.
  3. Press Print, set the destination to Save as PDF, and turn on "Background graphics" if code blocks look flat.
  4. Print one page as a test before you commit a long document.

That last step takes ten seconds. It catches margin surprises, orphaned headings and clipped tables while they are still cheap to fix.

Keep tables and long strings under control

A table wider than the page gets clipped or shrunk. Split wide tables, or turn the data on its side, as the tables guide explains. Long unbroken strings cause the same trouble. A URL pasted as plain text can run off the edge, so write it as a proper [link](url) instead.

Images and code blocks need a second look

Images print at their rendered size, so an oversized screenshot takes over a page. An inline <img width="400"> tag before printing keeps the layout balanced. Code blocks keep their shading only when background graphics are on, and a line that is too long is cut at the right edge rather than wrapped. Break long commands across lines yourself.

Why a PDF comes out wrong

Four problems account for nearly every disappointing PDF.

SymptomCauseFix
Code blocks look plainBackground graphics offEnable it in the print dialog
Table cut off at the rightTable wider than the pageFewer columns, or landscape
Long URL runs off the pageBare URL cannot wrapWrite it as a labelled link
Asterisks visible in the PDFYou printed the source panePrint with the preview showing

Printing the source pane is the classic one

Raw Markdown gives you a page full of ## and **, which is a document nobody wants to receive. The two inputs compare like this.

Printed from the source pane      Printed from the preview
## Quarterly report               Quarterly report  (large, bold)
Revenue rose **12%** this         Revenue rose 12% this quarter.
quarter.                          (12% in bold)

When a whole section disappears

Check the Markdown for an unclosed code fence. Everything after a stray triple backtick is swallowed into a code block, and the preview shows that too. Fix the fence and the section comes back. The code blocks reference covers fence rules in full.

Automated PDFs with Pandoc

Weekly reports, documentation releases and invoices built from templates are all recurring jobs. Pandoc builds those PDFs from the command line, using a LaTeX engine or a headless browser for layout.

pandoc report.md -o report.pdf
pandoc report.md --pdf-engine=weasyprint -o report.pdf
pandoc report.md --toc -V geometry:margin=2cm -o report.pdf

Choosing an engine

  • The default route needs a LaTeX installation. It is a heavy download, but the typography is book quality and page numbers come free.
  • --pdf-engine=weasyprint uses CSS instead, which feels far more familiar to web people and lets you reuse a stylesheet you already have.
  • --toc adds a real table of contents, and -V geometry:margin=2cm sets the margins from the command line.

When not to bother

For a one-off document this is overkill. The browser route gets you most of the quality for a fraction of the effort. If you want a web page rather than a document, converting Markdown to HTML is the other direction, and the .md download in the editor hands the source file straight back to you.

Related questions

Try the Editor

Open Editor