oka-project since 2024
JA Current language: English EN
Contact

Convert Markdown to PDF: Browser, VS Code, or Pandoc

Sep 12, 2026 · Updated Sep 15, 2026 Guide 7 min read

Convert Markdown to PDF with browser Print to PDF, the VS Code Markdown PDF extension, or Pandoc. Choose by whether the job is one-off, editor-based, or automated.

Contents (8)

If you need a PDF from a Markdown file, you do not necessarily need a file-conversion service. For a one-off export, the shortest route is to render the Markdown in your browser and use the browser's Print to PDF feature. If you need repeatable output, templates, or automation, Pandoc is usually a better choice.

The useful distinction is not "online vs. offline." It is where the document is processed, whether the content leaves your device, and whether you need the same result repeatedly.

Quick answer: browser for one-off PDFs, VS Code for editor-based export, Pandoc for automation

What you need Better option Why
Export one finished Markdown file Browser preview + Print to PDF No dedicated converter or setup
Edit an AI-generated draft before exporting Browser Markdown editor + Print to PDF Edit, preview, then export in one workflow
Save a README or note as a PDF Browser preview + Print to PDF Fast for a single document
You already write Markdown in VS Code Markdown PDF extension Export without leaving the editor
Reproduce the same PDF style Pandoc Settings can be kept in commands and templates
Convert many files Pandoc Easy to script or run in CI
Avoid sending the document to a conversion server A local-processing workflow Processing location matters more than whether the UI is a website

oka-project provides two browser tools for the first two cases. Markdown Viewer is for opening and checking an existing Markdown file. Yomu is for editing Markdown before you export it.

Both approaches use browser-side rendering for the document workflow rather than requiring the Markdown body to be sent to a PDF conversion API.

Method 1: render Markdown in the browser, then Print to PDF

This is the simplest option when the document is already mostly finished.

For a finished Markdown file

  1. Open Markdown Viewer.
  2. Choose a .md file or paste Markdown text.
  3. Check headings, tables, code blocks, and links in the preview.
  4. Open the browser print dialog: usually Ctrl + P on Windows/Linux or Command + P on macOS.
  5. Select the browser or operating system option to save as PDF.
  6. Check orientation, margins, scale, and page breaks before saving.

If you only need to inspect Markdown before exporting it, this is usually enough. The more general preview workflow is covered in Preview Markdown in Your Browser.

If you need to edit before exporting

Use Yomu when the Markdown still needs work.

A typical workflow is:

  1. Paste an AI-generated draft or open a Markdown/text file.
  2. Edit the source while watching the live preview.
  3. Fix headings, lists, tables, or code blocks.
  4. Open the PDF/print export.
  5. Save the rendered result as a PDF from the print dialog.

The advantage is not a different PDF engine. It is that editing and visual checking happen before the print step.

Browser-based does not automatically mean "no upload"

A web page can process a file locally, or it can upload the same file to a server. Both can look identical from the user's point of view.

Browsers provide APIs such as FileReader.readAsText() that let a page read a file you selected inside the browser. But JavaScript can also send that content to an API afterward.

If the document is sensitive, check:

  • whether the Markdown is uploaded to a server
  • whether the service stores the document
  • whether the page calls external APIs during conversion
  • whether external images or other resources are fetched
  • whether outbound connections are restricted by Content Security Policy (CSP)

oka-project's Markdown Viewer and Yomu are designed to process the Markdown content in the browser for these editing, preview, and export workflows. The tools also use CSP to restrict unnecessary outbound connections.

Method 2: export from VS Code with Markdown PDF

If VS Code is already your Markdown editor, you may not need to move the document into a separate browser tool just to create a PDF.

The current Markdown PDF extension in the Visual Studio Marketplace can export Markdown to PDF, HTML, PNG, and JPEG. It exposes commands such as markdown-pdf: Export (pdf) and can also convert on save.

Reference: Visual Studio Marketplace: Markdown PDF

VS Code itself already includes Markdown preview. The official documentation lists Ctrl+Shift+V on Windows/Linux and Shift+Command+V on macOS for opening the preview.

Reference: Visual Studio Code: Markdown and Visual Studio Code

When the VS Code route makes sense

Use it when you:

  • already edit the file in VS Code
  • want PDF and other export formats from the same editor
  • need CSS, headers, or footers
  • want export-on-save behavior

Local conversion does not always mean zero network traffic

The extension uses a Chromium-based PDF workflow. Its current documentation also describes managed Chromium behavior when a compatible browser is not available.

Optional features can create additional network paths. For example, Mermaid configuration can reference a CDN, and PlantUML can use a server.

So “the Markdown is not uploaded to a conversion service” and “the extension makes no network requests at all” are different claims.

For confidential documents or fully offline environments, check the extension settings and external resources, not only where the PDF is generated.

For a finished one-off document, browser Print to PDF may still be the simpler option.

Method 3: generate the PDF with Pandoc

For repeatable output, Pandoc is usually the more suitable tool.

The basic command is:

terminal
pandoc input.md -o output.pdf

Pandoc can produce PDF output through a PDF engine. Its current User’s Guide documents LaTeX as the default route and also supports other engines such as Typst, WeasyPrint, and wkhtmltopdf through --pdf-engine.

For example:

terminal
pandoc input.md --pdf-engine=xelatex -o output.pdf

The main advantage is not simply that Pandoc can create a PDF. It is that you can reuse the same generation rules.

That matters when you need:

  • consistent margins and typography
  • a table of contents
  • templates
  • repeatable builds
  • batch processing
  • CI or scripted document generation

The tradeoff is setup. For one file that you only need once, installing and configuring Pandoc plus a PDF engine may be more work than using the browser print dialog.

Four formatting problems to check before saving

Wide tables

A table that looks fine on screen may not fit on a portrait PDF page. Check the print preview and consider landscape orientation or a different scale.

If the table is not rendering correctly before the print step, fix the Markdown first rather than trying to solve it in PDF settings.

Long code lines

Long URLs, JSON, logs, or shell commands can run past the printable width. The browser may clip, wrap, or shrink them depending on the stylesheet.

Awkward page breaks

A heading can end up at the bottom of one page while its paragraph begins on the next. For long documents, inspect the saved PDF rather than assuming the screen preview and pagination will match.

External images

A Markdown document can reference images hosted on another domain. Even if the Markdown text itself stays on your device, displaying those images can create outbound requests.

If privacy matters, treat "the document was not uploaded" and "the page made no external requests" as separate questions.

Which method should you choose?

Use Markdown Viewer + Print to PDF when the file is finished and you only need a one-off export.

Use Yomu + Print to PDF when you want to edit the Markdown before exporting.

Use VS Code + Markdown PDF when Markdown already lives in VS Code and you want to export without changing tools.

Use Pandoc when output needs to be repeatable, automated, or controlled by reusable settings.

The important privacy question is the processing path. A browser tool can keep document processing local, while a desktop app can still sync data to a cloud service. Check the actual behavior rather than relying on the label.

Summary

For a single Markdown-to-PDF conversion, rendering the file in a browser and using Print to PDF is usually the fastest workflow. It avoids installing a dedicated conversion stack and can keep the document out of a remote conversion service when the tool is designed for local processing.

If you already write in VS Code, the Markdown PDF extension is a practical middle route. For repeatable or automated PDF generation, Pandoc is the stronger option because the conversion settings can be recorded and reused.

References

← All articles