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 available | Browser print dialog, Pandoc, editor extensions |
|---|---|
| Best print fidelity | Pandoc with a LaTeX engine |
| Install needed | None for the browser route |
| Links preserved | Yes, still clickable in the saved PDF |
| Page breaks | Automatic, nudge them with content or CSS |
How print to PDF actually works
- The browser prints the rendered preview, so the PDF shows formatting rather than Markdown symbols.
- The file is produced by your browser's own print engine, not by this site, so nothing is uploaded.
- Paper size, margins, scale and background graphics all live in the print dialog.
- Links stay clickable in the saved PDF, and page breaks are chosen for you.
The key idea is that the browser prints the rendered pane, not your source text. Headings keep their sizes. Tables keep their borders. Links stay clickable inside the saved file, and the source symbols never appear. That makes the preview your proof: whatever you see there is what the PDF will contain.
Page setup belongs to the browser, not to us. Paper size, margins, scale, headers and footers all live in the print dialog, and the wording differs a little between Chrome, Safari, Edge and Firefox. Page breaks are chosen automatically. If a heading lands at the very bottom of a page, adding a line or two above it usually nudges it over.
Tip: a horizontal rule before a major section gives readers a clean visual break, and it often pushes that section onto a fresh page at the same time.
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.
| Route | Install | Typography | Best for |
|---|---|---|---|
| Editor Print button | None | Good, browser styles | One document, immediately |
| Pandoc with LaTeX | Large download | Book quality, auto page numbers | Reports, theses, print |
| Pandoc with weasyprint | Python package | Styled by your own CSS | Web teams, branded output |
| VS Code extension | Editor add-on | Varies by extension | Exporting 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
- Start the document with a single
#title, so the PDF opens with a clear name. - Read the preview once and use heading levels in order, because that structure is all a printed page has.
- Press Print, set the destination to Save as PDF, and turn on "Background graphics" if code blocks look flat.
- 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.
| Symptom | Cause | Fix |
|---|---|---|
| Code blocks look plain | Background graphics off | Enable it in the print dialog |
| Table cut off at the right | Table wider than the page | Fewer columns, or landscape |
| Long URL runs off the page | Bare URL cannot wrap | Write it as a labelled link |
| Asterisks visible in the PDF | You printed the source pane | Print 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=weasyprintuses CSS instead, which feels far more familiar to web people and lets you reuse a stylesheet you already have.--tocadds a real table of contents, and-V geometry:margin=2cmsets 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