MD to PDF

Markdown to PDF
without the extension

The usual VS Code route is an extension that downloads its own copy of Chromium and often falls over doing it. Paste the Markdown here instead and skip the install entirely.

document.md
Source
77 lines · 308 wordsLn 1, Col 1

Why the VS Code extensions tend to fail

Producing a PDF needs a browser engine, and a VS Code extension has to obtain one. The popular Markdown PDF extension downloads a private copy of Chromium the first time you run it, which is where most of the reported trouble starts.

  • The download is large and goes to a Google host, so it fails on corporate networks, behind proxies and on machines with restricted egress
  • The failure is often silent or reported as a generic error, so it is not obvious that a download is what broke
  • Mermaid diagrams and LaTeX maths need extra configuration and frequently come out blank
  • Page setup is controlled through JSON settings rather than anything you can see, so the first indication that the margins are wrong is the finished file

The install-free route

Select all in the editor, copy, and paste into this page — or drag the .md file straight from the VS Code explorer onto it. The preview is the real page at the real width with the real margins, so you can correct the layout before producing anything rather than after. Nothing is installed and nothing is configured.

What you get that the extension does not give you

The differences are mostly the things that need a configured engine to work at all.

  • Mermaid diagrams and KaTeX maths render with no configuration
  • Every heading becomes a real PDF bookmark rather than flat text
  • Page size, margins, typeface and page numbers are visible controls with a live preview
  • Syntax highlighting in around 200 languages, matching what you see in the editor

If you would rather keep it local

A web tool is not always the right answer — for a build step, a private document, or an offline machine, a local converter is better. Pandoc is the dependable one, and with a LaTeX engine installed the whole job is a single command:

  • pandoc notes.md -o notes.pdf
  • Add --toc for a table of contents, and -V geometry:margin=1in to set the margins
  • It needs pandoc plus a TeX distribution, which is a large install, and Mermaid diagrams still require a separate filter

Common questions

How do I convert Markdown to PDF in VS Code without an extension?

Copy the file's contents out of the editor and paste them here, or drag the .md file from the VS Code explorer onto this page, then click Download PDF. Nothing is installed.

Why does the Markdown PDF extension not work?

It downloads its own copy of Chromium on first use. That download fails on restricted or proxied networks, and the resulting error rarely makes the cause clear.

Can I convert Markdown to PDF from the command line instead?

Yes — pandoc notes.md -o notes.pdf, with pandoc and a TeX distribution installed. It is a large install and Mermaid diagrams need an extra filter, but it works offline and fits into a build.