How to convert Markdown to PDF without losing the formatting
A four-minute read.
Markdown becomes PDF in three ways, and they differ less in the result than in how much work it takes to get there.
1. Through the browser, by printing
Any Markdown previewer plus Ctrl+P gives you a PDF. It is the shortest path and the least predictable one: margins, page breaks and font size are decided by the previewer's stylesheet, which was almost never designed for paper. The browser's own header and footer come along, with the date and the page address, unless you remember to switch them off.
2. From the command line
Pandoc converts Markdown to nearly anything, PDF included, with full control — as long as you accept installing a multi-gigabyte LaTeX distribution and learning a template syntax. For anyone who already has that set up, it is the best answer. For anyone who needs to send a document today, it is a project instead of a task.
3. From an editor that already exports
This is the path with no intermediate step: the document on screen is what lands in the file. The thing to check is whether the editor shows what will come out. Many export with a different theme from the one you wrote in, and the surprise arrives with the PDF already made.
Why the PDF usually comes out ugly
It is not Markdown's fault. It is that most conversions treat the document as a web page sent to a printer: tight leading, a column too wide for the eye to find the start of the next line, headings the same size as the body, and no rule against a heading stranded at the foot of a page.
What makes a document look considered is typography: a measure of around 66 characters, generous leading, visible hierarchy between heading and body, and margins that breathe. These are decisions someone has to make once — and almost no converter makes them.
In KempDec Markdown
The editor screen carries the measurements of the PDF page. Export asks for the paper size and shows how many pages will come out before you click; there is no multi-step wizard and no separate theme for printing.
The file is built by the editor itself, not by the browser print dialog: it comes out with no header, no footer and no page address, and it carries the drawing along — the code block highlight, the table header band, the quote bar and the images you pasted.
It works without a connection after the first visit, and the file stays your .md — the PDF is an output, not the format the document moves into.