DashConvert
4 min read

How to convert Markdown to PDF (with syntax highlighting and tables that don't break)

Markdown to PDF sounds trivial and mostly is โ€” until you hit code blocks, tables wider than the page, and images that misalign. What actually works, based on what developers repeatedly ask about on Reddit.

Why developers keep asking about this

Search "markdown to pdf" on r/ObsidianMD, r/Notion, r/programming, or r/vscode and you'll find the same complaints repeatedly:

  • Pandoc works but requires LaTeX for anything beyond plain text.
  • VS Code extensions render inconsistently across machines.
  • Online converters strip syntax highlighting from code blocks.
  • Tables wider than the page silently overflow or get chopped.

Most people just want: "give me a PDF that looks like the rendered Markdown on GitHub." That's the bar.

The one-line answer

For a single .md file, Markdown to PDF in your browser produces GitHub-style output โ€” proper heading hierarchy, syntax-highlighted code blocks, tables with visible borders, working links. Drop the file, download the PDF. No LaTeX install, no CLI, no server upload.

For a whole documentation site (multiple files), use Pandoc or MkDocs โ†’ PDF. That's outside browser-tool scope.

What "good Markdown to PDF" actually means

Four things are non-negotiable for a usable output:

  1. Syntax highlighting on code blocks. ```js should render with keyword coloring, not as plain monospace.
  2. Tables render with borders and correct alignment. Not just as unstyled rows.
  3. Headings generate a navigable outline. Chrome and Adobe Reader both show a sidebar from PDF bookmarks.
  4. Links are clickable in the output. [docs](https://example.com) should be a live link, not just blue text.

Missing any one of these is why so many "markdown to pdf" outputs feel amateurish.

Tables that don't overflow

The biggest complaint on r/technicalwriting: Markdown tables can be any width, but PDF pages can't. If your table has 8 columns of code samples, it will overflow the right edge and get truncated.

Three fixes ordered by ease:

  1. Reduce column count if the table has redundant columns.
  2. Set landscape orientation if the table is wide but manageable. Most converters expose this.
  3. Wrap long text cells โ€” force text wrapping so cell width doesn't dictate table width.

If none of those work, the source is genuinely too wide for a page and needs to be split into two tables.

Code blocks and syntax highlighting

Fenced code blocks (```lang) work in Markdown to PDF with syntax highlighting for the common languages (JS/TS, Python, Rust, Go, Java, C/C++, SQL, HTML/CSS, shell). Long lines don't wrap by default โ€” they scroll horizontally on the rendered page. Since PDFs don't scroll, long code lines get cut off.

Fix at the source: either break lines manually or use shorter variable names in code destined for print. There's no clean automatic fix โ€” soft-wrapping code changes its meaning in whitespace-sensitive languages like Python.

Images and diagrams

Local image paths (![alt](./diagram.png)) work if the tool has access to the file. Browser-based tools including Markdown to PDF let you drop the image files alongside the Markdown file and they get inlined into the PDF.

For Mermaid diagrams: some Markdown-to-PDF tools render them, some don't. If yours doesn't, export the Mermaid diagram as PNG first and reference the PNG.

When to use Text to PDF instead

If your source is genuinely plain text โ€” no formatting, just text โ€” Text to PDF is simpler and produces a cleaner output than treating it as Markdown. The Markdown renderer will interpret *, _, and # characters even when you didn't mean them as syntax.

After the conversion

Common follow-ups:

  • Combining multiple chapter PDFs into a book: Merge PDF.
  • Converting a rendered Markdown page (HTML in a browser tab) to PDF instead: HTML to PDF.

The privacy piece

Internal engineering docs, product specifications, API keys accidentally left in code blocks โ€” Markdown files often carry more sensitive content than people realize. Markdown to PDF runs the entire conversion in your browser. The file never uploads. This matters more than it seems for internal-only documentation.

Tools mentioned in this post