# Markdown to PDF: 5 ways to convert an MD file

> How to convert Markdown to PDF: print from a preview, VS Code, an online md to pdf converter, Pandoc, or hosted typesetting, and where each one stops.

Canonical: https://buk.press/blog/markdown-to-pdf-guide

21 August 2026 · 8 min read · Updated 20 October 2026

To convert Markdown to PDF, open the .md file in a tool that renders it and export: print to PDF from a browser preview, use a VS Code extension, paste it into an online converter, run Pandoc from the command line, or use a hosted typesetting tool. The quick routes are fine for a draft; for a document someone will read, sell or print, pick the route that gives you real page breaks, embedded fonts and margins you chose.

To convert Markdown to PDF, open your .md file in something that renders it and export the result: a browser preview, a VS Code extension, an online converter, Pandoc, or a hosted typesetting tool. All five turn an MD file into a PDF; they differ in how much control you get over the page, and the page is the whole problem.

Markdown has no concept of a page. It describes structure (this is a heading, this is a list) and says nothing about where paper ends. Every tool below is a different answer to that gap, so that is the axis worth comparing them on. If you are new to the syntax itself, the [Markdown cheat sheet](https://buk.press/blog/markdown-cheat-sheet) covers it first.

## How do I convert a Markdown file to PDF?

The shortest version, whichever tool you use:

1. **Open the .md file** in a tool that renders Markdown (a preview pane, an editor, a converter page).
2. **Check the rendered result**: headings, lists, tables and images should look like the structure you wrote.
3. **Set the page**, if the tool lets you: page size, margins, fonts, page numbers.
4. **Export or print to PDF**, then open the file on another device to confirm the fonts and breaks held.

Step 3 is where the tools split. Here is what each route actually does, what it is good at, and what will eventually make you look for something else.

## 1. Print to PDF from a preview

Open your Markdown in any preview (a browser, an editor pane, a notes app) and print to PDF. It costs nothing and takes ten seconds.

**Good for:** a draft someone needs to read once. Internal notes. Anything where the file is a courier and nobody looks at it twice.

**Where it stops:** you are printing a web page, not making a book. The browser decides where pages break, and it decides badly: headings stranded at the bottom of a page, tables that lose their header row halfway down, an image torn across the fold. You get the browser's own header and footer unless you remember to turn them off. Margins are whatever the print dialog offers, and the typefaces are whatever the preview happened to use.

The tell is always the same: open your printed PDF on a different machine and see whether it still looks like the thing you printed.

## 2. Can VS Code convert Markdown to PDF?

Yes, through an extension. Extensions such as Markdown PDF render your file through a headless browser and save the result as a PDF. This is a real step up from printing, because you can point them at a CSS file, so the type and spacing become yours rather than the default stylesheet's.

**Good for:** developers who are already in the editor, want repeatable output, and are comfortable writing CSS to get it. There is a longer walkthrough in [writing a book in VS Code](https://buk.press/blog/writing-a-book-in-vs-code).

**Where it stops:** you are now maintaining a stylesheet for print, which is a different discipline from styling a screen. Page breaks, running headers, widow and orphan control and page numbering all live in CSS rules you have probably never needed before, and browser support for the print-specific ones is uneven. It works, and then a month later you are debugging why `page-break-inside: avoid` did nothing.

## 3. Is there a free Markdown to PDF converter online?

Yes, several. Paste Markdown into a box, get a PDF back: no install, no account, no learning curve. That is what a search for "md to pdf" usually wants, and for a one-off file it is a fair answer.

**Good for:** one file, once, when the look does not matter.

**Where it stops:** in three places. The output is generic: one default look, little or no control over type or margins. Some converters add their own branding to the file, which is fine for a memo and not fine for anything you intend to sell or hand to a client. And you are uploading a document to a service whose retention policy you have probably not read, which is worth a thought if the draft is not yours to leak.

If what you want is an online editor first and a PDF second, [online Markdown editors compared](https://buk.press/blog/markdown-editor-online) sorts them by job.

## 4. How do I convert Markdown to PDF with Pandoc?

Pandoc is the serious command-line answer, and it deserves its reputation. Pointed at a LaTeX engine, it produces properly typeset pages, with the hyphenation and justification decisions that make a page look professionally set rather than merely tidy.

```
<code>pandoc book.md -o book.pdf --pdf-engine=xelatex</code>
```

**Good for:** technical books, academic work, anything with heavy cross-referencing, citations or mathematics. If your document has a bibliography, this is the correct tool. [Pandoc for books](https://buk.press/blog/pandoc-for-books) goes through the flags that matter.

**Where it stops:** the first command works. The second week is harder. Changing a typeface means learning `fontspec`. Changing margins means `geometry`. A cover image, a different look for chapter openings, or a running header with the chapter name means a custom template, which means learning enough LaTeX to debug someone else's. There is also no live preview: you compile, look, adjust and compile again, and the loop is slow enough that you stop adjusting long before the document is right.

None of this is a criticism of Pandoc. It is a conversion engine of extraordinary range, and the ceiling is higher than anything else here. The cost is that the ceiling is reached by programming. It also converts Markdown to Word: see [Markdown to Word](https://buk.press/blog/markdown-to-word).

## 5. A hosted typesetting tool

The last route is to hand the page problem to something built for it: you keep writing Markdown, and the pagination, font embedding and layout are handled, with the design exposed as a handful of controls rather than a configuration language.

This is what [bukpress](https://buk.press/) does. Type is three choices (title, subtitle, body), each with its own size and colour. The page is a paper texture or your own image, with margins in points and page numbers on or off. A line of `---` is a hard page break, and a table that runs past the bottom of a page repeats its header row on the next. The preview paginates with the same rules the export uses, so a break on page seven on screen should land on page seven in the file, with the export as the final word.

**Good for:** anyone whose bottleneck is the design rather than the writing, and who wants the output to be defensible without becoming a typesetter to get there. Lifetime, $27 once, exports unlimited PDFs and EPUBs, books up to 500 pages, with no watermark.

**Where it stops:** it is opinionated. The page is A4, the export is PDF (and EPUB), and you get the controls a book needs rather than an arbitrary layout canvas: no text wrapping around a floated illustration, no multi-column spreads, no pinning an element to a spot on page four. If your document is really a designed artefact rather than a book or report, a layout application is still the right tool.

## Markdown to PDF converters side by side

|  | Print | VS Code | Online | Pandoc | Hosted |
|---|---|---|---|---|---|
| Setup | None | Minutes | None | Hours | None |
| Control over type | None | Via CSS | Little | Via LaTeX | Direct |
| Real page breaks | No | Fragile | Rarely | Yes | Yes |
| Fonts embedded | Sometimes | Yes | Varies | Yes | Yes |
| Live preview of pages | No | No | No | No | Yes |
| Covers | No | Manual | No | Template | Upload |
| Cost | Free | Free | Free or paid | Free | Free to preview, paid to export |

## Which Markdown to PDF route should you pick?

Ask what happens to the file after you make it.

- **Read once, then discarded**: print to PDF and stop there.
- **Regenerated constantly by a build**: Pandoc, or a VS Code extension if the styling needs are light.
- **Cited, with mathematics or a bibliography**: Pandoc with LaTeX. This is not a close call.
- **Sold, sent to a client, or printed**: you need control over the page, and the choice is between learning a typesetting system and using one that has already been configured.

The mistake worth avoiding is the middle: three evenings fighting a print stylesheet for a document that needed to be finished on Tuesday. Pick by the document's destination, not by which tool you happened to open first.

## Markdown to PDF questions

### How do I force a page break in a Markdown PDF?

Standard Markdown has no page break. Most tools need raw HTML such as a div with `page-break-after: always`, or a LaTeX `\newpage` in Pandoc. In bukpress a line of `---` on its own is a page break. [Markdown page breaks](https://buk.press/blog/markdown-page-breaks) covers every tool.

### Why do my fonts change when someone else opens the PDF?

Because the fonts were not embedded. A PDF that references a font instead of carrying it falls back to whatever the reader's machine has. [PDF font embedding](https://buk.press/blog/pdf-font-embedding) explains how to check and fix it.

### Can I convert MD to PDF on a phone?

An online converter works in a mobile browser for a quick file. For anything longer, a browser-based editor with export does the same job without a local install, because the render happens on the server.

## Next step

If you want to see the far end of that spectrum before choosing, [the sample book](https://buk.press/sample-book) is eight pages exported from bukpress with nothing touched afterwards: page breaks, a real table, embedded type and the margins actually set. Open it, then try your own Markdown file in the editor, with a 7-day refund if it isn't for you.

**About this article.** Written by the team that builds bukpress, which turns Markdown into print-ready PDF and EPUB books. Last checked 20 October 2026. Spotted something wrong or out of date? Write to [support@buk.press](mailto:support@buk.press).

## Read next

How-to 21 August 2026 · 4 min read

## [How to control page breaks in Markdown](https://buk.press/blog/markdown-page-breaks)

Markdown has no page break because it describes structure, not pages, so every method is really an instruction to whatever renders it. The three that work are a raw HTML div with a CSS page-break rule, a LaTeX \newpage command through Pandoc, or a renderer that assigns a meaning to a plain-text marker.

[Read it](https://buk.press/blog/markdown-page-breaks)

Tools 30 August 2026 · 5 min read

## [Pandoc Markdown to PDF: the commands, and where it stops](https://buk.press/blog/pandoc-for-books)

To convert Markdown to PDF with Pandoc, install Pandoc and a PDF engine (a LaTeX distribution such as TeX Live or MiKTeX, or an alternative like Typst or WeasyPrint), then run pandoc input.md -o output.pdf. Add --pdf-engine=xelatex to use your own fonts, -V geometry:margin=2.5cm for margins and --toc for a contents page. Pandoc is the best tool for documents with citations, cross-references or mathematics, and for books built by a script; it stops being pragmatic when the requirements are visual, because every visual change means LaTeX or a template.

[Read it](https://buk.press/blog/pandoc-for-books)

Explainers 26 August 2026 · 4 min read

## [Why your PDF looks wrong on someone else's computer](https://buk.press/blog/pdf-font-embedding)

Because the font was referenced rather than embedded. A PDF can either carry a copy of the typeface inside the file or just name it and hope the reader's machine has it, and when it does not, the reader silently substitutes something else, which changes the line breaks and the page count along with the look.

[Read it](https://buk.press/blog/pdf-font-embedding)

## Write it in Markdown. Ship a book.

bukpress turns the file you are already writing into a typeset PDF and EPUB: your type, your covers, no watermark, ever.

[Get Lifetime, $27 once](https://app.buk.press/signup)
