Skip to the tool
CALCPARK

Markdown to PDF

Convert Markdown to a PDF in your browser: headings, lists, tables, code and links with real selectable text, or image pages for any script. A4/Letter, margins, sizes.

Files stay on your device
Loading the tool…

How to use it

  1. Paste Markdown into the editor, drop a .md file, or press “Load sample document”. The Preview tab shows how it will be laid out.
  2. Pick paper, orientation, margins and font size. Leave “Output” on Automatic: it uses selectable text whenever the fonts can show every character.
  3. Press “Convert to PDF”. The result shows the page count, file size and whether the text is selectable.
  4. Download. The file is named after the .md file you loaded, or markdown.pdf.

Example

The sample document (a status report with a heading, two sub-headings, a bullet list, a 4-row table, a numbered list, a quote and a code block) on A4 portrait with 0.79 in margins at 11 pt fits on 1 page as selectable text, roughly 25 KB. The same document as image pages at 200 dpi is one 1,339 × 1,893 px JPEG of about 250 KB. Switching to 14 pt pushes it to 2 pages; the second page starts at the first blank line after the table rather than mid-row.

How the conversion works

markdown-it turns the Markdown into HTML (raw HTML in the source is escaped, not executed). The HTML is laid out off-screen at 96 px/in with a print stylesheet whose sizes are in points, so both output modes share the same geometry: for A4 with 0.79 in margins the text column is 481.9 pt wide.

Selectable text uses jsPDF’s html() renderer with autoPaging: 'text': html2canvas parses the layout and jsPDF replays it as PDF drawing operations, mapping the fonts to the 14 standard PDF fonts (Helvetica for text, Courier for code). Those fonts cover WinAnsi only, which is why the tool checks every character first and falls back to images when needed. Image pages use html2canvas to capture one page-high slice at a time at the chosen dpi, look upwards through the last 12% of the slice for a row of pure background to cut on, and place each slice as a JPEG (quality 0.92) on a page with pdf-lib.

Limits

  • No KaTeX formulas, footnotes or syntax highlighting in the PDF (plain monospace code blocks).
  • Selectable mode cannot embed custom fonts; non-Latin text always becomes image pages.
  • Images referenced by URL need to be fetchable from your browser (CORS); otherwise they are left blank.
  • Very long documents (hundreds of pages) are slow in image mode because every page is rendered separately.

Sources: CommonMark specification, jsPDF – html() API, PDF 32000-1:2008 – Annex D, standard Latin character set (WinAnsiEncoding).

Questions

Why is my text not selectable in the PDF?
Either you chose "Image pages", or the document contains characters the standard PDF fonts cannot encode (the Output field names them). Replace or remove those characters and convert again to get selectable text.
Does it support tables and code blocks?
Yes. GitHub-style pipe tables become bordered tables with column alignment; fenced code blocks are set in Courier on a grey background and wrap long lines instead of being cut off.
Which resolution should I pick for image pages?
200 dpi is sharp on screens and fine for office printers. Use 300 dpi for print shops and 150 dpi when the file must stay small (about half the size of 200 dpi).
Is my document uploaded anywhere?
No. Rendering, page splitting and PDF writing all happen in the browser; the libraries are part of the page. Only images linked by URL are fetched from their own servers.