How to Convert Markdown to PDF: 3 Reliable Methods
Choose a fast visual export, a reproducible command-line pipeline, or a browser workflow—and avoid the formatting problems that usually appear after conversion.
To convert Markdown to PDF, open the .md file in an editor that can render Markdown, check the preview, and choose Export PDF. That is the simplest route for one document. Use Pandoc when you need repeatable builds, templates, citations, or batch conversion.
Quick recommendation
Windows and visual export: Hashdraft. Automated publishing: Pandoc. One simple document with no new app: render to HTML and use the browser's Print to PDF command.
Choose the right conversion method
| Method | Best for | Setup | Main tradeoff |
|---|---|---|---|
| Desktop Markdown editor | Reports, notes, documentation, occasional export | Low | Layout options depend on the app |
| Pandoc | Books, papers, CI builds, branded templates, batch jobs | Medium to high | PDF engines and templates take time to configure |
| HTML + browser print | Simple, occasional conversion | Low | Browser headers, margins, and page breaks need attention |
All three methods first interpret Markdown as structured content and then lay that content out on fixed PDF pages. Conversion problems usually come from the second step: a web-like document can scroll forever, while a PDF must decide exactly where every page ends.
Method 1: Export Markdown to PDF in Hashdraft
This is the shortest local workflow on Windows. Hashdraft renders the document natively and exports that rendered result directly to PDF. Your source file stays on your computer, and no account or browser is required.
- Open the Markdown file. Drag a
.mdfile into Hashdraft or use the Open command. - Review Preview or Split mode. Check the heading hierarchy, tables, images, task lists, code blocks, footnotes, and math before exporting.
- Choose Export PDF…. Select a destination and file name, then save.
- Open the resulting PDF. Inspect page breaks, image quality, selectable text, and clickable links rather than assuming the export is finished.
Hashdraft includes PT Serif, PT Sans, and JetBrains Mono, so prose and code have consistent local fonts without installing a separate font pack. It also supports local images, tables, syntax-highlighted code, footnotes, YAML front matter, and LaTeX math.
Best fit
Use Hashdraft when you want to see the finished document while writing and produce a clean PDF without maintaining a publishing toolchain. Download the free Windows app.
Method 2: Convert Markdown to PDF with Pandoc
Pandoc is a document converter designed for reproducible publishing. It can read several Markdown flavors and generate PDF through LaTeX, ConTeXt, Typst, HTML-based engines, and other back ends. This flexibility is valuable when documents need a table of contents, numbered sections, bibliographies, templates, or an automated build.
Basic Pandoc command
After installing Pandoc and a supported PDF engine, run:
pandoc document.md -o document.pdf
Pandoc infers the input and output formats from the extensions. Its default PDF route normally requires a LaTeX engine. The exact dependency is important: installing Pandoc alone may not be enough for local PDF output.
Useful PDF options
pandoc document.md \
--pdf-engine=xelatex \
--toc \
--number-sections \
-V geometry:margin=1in \
-V mainfont="Noto Serif" \
-o document.pdf
--pdf-engine=xelatexselects a Unicode-friendly LaTeX engine.--tocbuilds a table of contents from headings.--number-sectionsnumbers sections automatically.-V geometry:margin=1insets page margins through a template variable.-V mainfont=...selects an installed font when the chosen engine supports it.
For a long-lived project, move options into a Pandoc defaults file. Then every contributor and CI job can build the same output without copying a large command.
When Pandoc is the better choice
- You publish many files with one design.
- The PDF must include citations and a bibliography.
- You need headers, footers, section numbering, or a journal template.
- The document is built in GitHub Actions or another CI system.
- You need PDF plus DOCX, EPUB, HTML, or slides from the same source.
Pandoc is powerful because it separates content from the publishing pipeline. That same separation makes it more setup-heavy than clicking Export in a desktop editor.
Method 3: Render HTML and print to PDF
If you already have rendered HTML, a modern browser can save it as PDF. This route is useful for a one-off document and gives you control through print CSS.
- Convert or preview the Markdown as HTML. Confirm that the chosen renderer supports the syntax in your document.
- Open the rendered page in a browser. Do not print the raw Markdown source.
- Open Print and choose Save as PDF. Set paper size, orientation, margins, scale, and whether background graphics should be included.
- Disable browser headers and footers unless you intentionally want the URL, title, and print date on every page.
- Save and verify the PDF. Pay special attention to code, tables, and content split across pages.
If you own the HTML template, print CSS can prevent awkward splits:
@media print {
h2, h3 { break-after: avoid; }
pre, table, figure { break-inside: avoid; }
a { color: inherit; text-decoration: underline; }
}
These are preferences, not guarantees. A table or code block taller than a page still has to split or overflow.
Prepare the Markdown before exporting
A clean source document produces a cleaner PDF in every tool.
- Use one level-one heading. Treat it as the document title, then nest sections in order.
- Give images useful alt text. Even when the current PDF is visual, the source may later become accessible HTML or an EPUB. Check paths and sizing in the Markdown images guide.
- Use relative image paths. Keep assets inside the project instead of linking to a user-specific folder.
- Specify code languages. Write
```python, not only```, when syntax highlighting matters. - Avoid extremely wide tables. Split them, shorten labels, or use landscape layout.
- Prefer HTTPS links. Link text should explain the destination when the PDF is read on screen and still make sense if printed.
Fix common Markdown-to-PDF problems
Images are missing
The renderer cannot resolve the image location. Check filename capitalization, slashes, and the path relative to the Markdown file or working directory. Remote images can also fail when the converter is offline or the server blocks hotlinking. Local project assets are more dependable.
Text uses the wrong font or shows empty boxes
The chosen font may be unavailable or lack glyphs for the document's language. Select a Unicode font installed on the build machine and use a PDF engine that supports it. With Pandoc, XeLaTeX or LuaLaTeX is often a better fit than a legacy default for multilingual documents.
Code runs off the page
PDF pages cannot scroll horizontally. Wrap long lines before export, use a smaller monospace font, or switch the affected page to landscape. Automatic wrapping is convenient for prose but can make source code misleading, so manual line breaks are often safer.
Headings are stranded at the bottom
Use a template or print stylesheet that avoids a break immediately after headings. Also remove manual blank lines: they do not create reliable page spacing and can interact differently with each renderer.
Tables are clipped
Reduce the number of columns, shorten cell content, or use landscape orientation. For complex data, a chart or a separate appendix may communicate better than shrinking a table until it is unreadable.
Links are not clickable
Not every PDF pipeline preserves hyperlinks. Confirm that the Markdown uses valid destinations, then test the actual exported file. If the PDF may be printed, include meaningful link text or a short visible URL for essential destinations.
PDF quality checklist
- The title, author, and date are correct.
- Heading levels form a logical outline.
- No heading is left alone at the bottom of a page.
- Tables and code blocks fit or split cleanly.
- Images are sharp at normal zoom and include captions where needed.
- Page numbers, headers, and footers are intentional.
- Text can be selected and searched.
- Important links work in a PDF reader.
- The document opens on another device.
- The filename is descriptive and versioned appropriately.
Frequently asked questions
Can I convert Markdown to PDF without uploading the file?
Yes. Use a local desktop editor such as Hashdraft or install Pandoc and a PDF engine. Both workflows can keep the source and output on your computer.
Does a PDF keep clickable Markdown links?
Usually, but support depends on the renderer and PDF engine. Always click-test important links in the exported file.
Why are images missing from my Markdown PDF?
The most common cause is a path the converter cannot resolve. Keep images inside the project, use valid relative paths, and run command-line tools from the expected working directory.
What is the best Markdown-to-PDF method?
Use a desktop editor for quick, visual export; Pandoc for automated or highly controlled publishing; and browser print for an occasional simple document.
Export Markdown to PDF without uploading it
Open your file, inspect the finished layout, and create a clean PDF directly on Windows. Hashdraft works locally and needs no account.