Free online tool

Upload a file

Drop your file hereTap to choose a file

or click to browse, or paste from the clipboard

← Back to Blog

How to Convert Markdown to PDF with Images, Tables and Page Breaks

To convert Markdown to PDF, render the Markdown as formatted text and save that page as a PDF file. The quickest way is to open or paste your .md file in Markdown to PDF, check the live preview and select Export PDF: you get a searchable PDF with tables, code blocks, clickable links and embedded images.

VS Code (with the Markdown PDF extension) and Pandoc do the same job on your own computer. Whichever you use, images and page breaks need one extra step each.

How to convert Markdown to PDF with Zutilium

  1. Open Markdown to PDF. Select Open Markdown to load a UTF-8 .md, .markdown or .txt file, or select Clear to remove the sample and paste your text into the Markdown pane.
  2. Put the cursor where a picture belongs and select Insert image. Use Page break wherever a new page should start.
  3. Choose Paper size (A4, Letter or A5) and Orientation, then set Margins (mm) between 10 and 30 and Text size (pt) between 10 and 18. The defaults are A4 portrait, 18 mm and 12 pt.
  4. Pick a Font style (Sans serif or Serif) and a Document theme: Classic keeps headings near-black, Modern makes them blue. Leave Page numbers checked to print numbers such as "1 / 3" centered at the foot of each page.
  5. Check Document name. Opening a file fills it in, and it becomes both the PDF's file name and its title.
  6. Select Export PDF, or press Ctrl+Enter in the editor (Command+Enter on a Mac). When the status line confirms the PDF is ready and shows its page count, select Download PDF.

The live preview is one continuous page, so check where pages end in the PDF itself. Before exporting, read any warning at the bottom of the workspace: it flags images that will not load, unsupported links and raw HTML.

Editing and the preview run in your browser. Export PDF uploads the current Markdown, including embedded images, to Zutilium's server for conversion, and the PDF download is temporary. The editor keeps a draft only in the current tab, so select Download Markdown to keep your source.

What carries over from Markdown to the PDF

The PDF uses the same HTML, styles and fonts as the preview, so the preview shows what you will get, apart from page breaks.

Markdown In the PDF
Headings, bold, italic, strikethrough, lists, quotes Formatted as in the preview
Tables Full width, equal columns, header row repeated on new pages
Fenced code blocks Monospaced box, long lines wrap, no syntax colors
Task lists Checked and empty boxes
Links and bare URLs (http, https, mailto) Clickable
Links to other files, such as setup.md Plain text
Images Only embedded ones, added with Insert image
Raw HTML, footnotes, $math$, Mermaid Printed as text, not rendered (asterisks inside math can still become italics)
YAML front matter A horizontal line and a heading

Alignment colons in a table's separator row, such as ---:, have no effect, so number columns are left-aligned too.

Need an editable file instead? Markdown to Word creates a DOCX (see the editable DOCX example). For a web page, see how to convert Markdown to HTML.

Markdown to PDF with images

A Markdown image is only a pointer: ![Diagram](images/diagram.png) tells the converter where to find a file. A program on your computer can follow that relative path, but a website cannot see your folders. Zutilium's exporter also blocks all network requests, so it never downloads images from URLs. Both kinds appear in the PDF as a placeholder such as [Image: Diagram. Use Insert image.].

Insert image solves this. It reads a PNG, JPEG, WebP or GIF from your device and writes it into the Markdown as a base64 data URL, so the source gains one very long line containing data:image/. Animated GIFs print as a still image, and SVG files are not accepted, so export diagrams as PNG first.

The size budget, worked out

Base64 stores every 3 bytes of an image as 4 characters, so embedding adds a third. Each inserted file can be up to 1 MiB, but the whole Markdown, text and images together, must stay within 2 MiB:

  • A 704 KiB JPEG adds about 939 KiB to the Markdown.
  • One 1 MiB image takes about 1.33 MiB, leaving roughly 683 KiB for everything else.
  • Two 1 MiB images (about 2.67 MiB) cannot fit.
  • All your image files together can total about 1.5 MiB (2 MiB × 3 ÷ 4), minus the text.

The line under the editor shows the running size against the 2 MiB limit. A document can also hold at most 32 images, each up to 16 megapixels, with 32 megapixels combined. If a picture is over 1 MiB, shrink it to a set file size before inserting it.

How big will an image print?

Images print at 96 pixels per inch, the CSS definition of a pixel, until they reach the width of the text column; wider images shrink to fit. On A4 portrait with the default 18 mm margins, the column is 174 mm (6.85 in), so any image wider than about 658 pixels fills it. On Letter portrait it is 180 mm, about 680 pixels.

Image width Printed width on A4 Pixels per inch
600 px 159 mm (6.25 in) 96
1,000 px 174 mm (6.85 in) 146
1,600 px 174 mm (6.85 in) 234

Small images stay small, while wide screenshots get sharper as they shrink. Tall images, such as phone screenshots, are scaled down to fit on one page rather than split.

With VS Code or Pandoc, use relative paths to images stored beside the Markdown file. Pandoc resolves them from the folder you run it in, not the file's folder (see below).

Page breaks, tables and page layout

Markdown has no page-break syntax, so each converter defines its own marker. In Zutilium, the Page break button inserts this line, and the preview marks it with a dashed line:

<!-- pagebreak -->

It must sit on its own line, spelled exactly like this. Markers written for other tools print as visible text, including \newpage and <!--pagebreak--> without spaces:

Converter Page break marker
Zutilium Markdown to PDF <!-- pagebreak -->
Pandoc with a LaTeX engine \newpage
VS Code with Markdown PDF <div class="page"/>

Without markers, the export tries to keep each heading with the text that follows it and avoids splitting a table row or an image across two pages.

Tables always span the text width with equal columns and wrap long words, so nothing runs off the page, but a seven-column table gets narrow columns. Switch Orientation to Landscape (the A4 column grows from 174 mm to 261 mm), lower Margins (mm) to 10, or reduce Text size (pt). Code blocks wrap long lines instead of cutting them off.

A single export can have up to 100 pages and 20 MiB, so export longer documents in parts. To stamp DRAFT or a logo on every page afterwards, use PDF Watermark & Page Numbers.

Convert MD to PDF in VS Code or with Pandoc

Export Markdown as PDF in VS Code

VS Code's built-in Markdown preview (Ctrl+Shift+V, or Shift+Command+V on a Mac) shows the formatted file but has no PDF export. The Markdown PDF extension adds one:

  1. Install Markdown PDF (publisher yzane) from the Extensions view.
  2. Open your .md file, press F1 or Ctrl+Shift+P (Command+Shift+P on a Mac) and type export.
  3. Choose markdown-pdf: Export (pdf).

It prints through Chrome, Edge or Chromium, downloading Chromium on first use if none is installed. Code blocks get syntax colors, and the default paper size is A4.

Convert Markdown to PDF with Pandoc

Pandoc converts from the command line:

pandoc notes.md -o notes.pdf

By default Pandoc builds the PDF with LaTeX (pdflatex), so a LaTeX distribution has to be installed; without one, the command stops with an error that names pdflatex. Common additions:

# Set margins and use an engine that handles system fonts
pandoc notes.md -o notes.pdf --pdf-engine=xelatex -V geometry:margin=2cm

# Run from another folder: tell Pandoc where the images are
pandoc docs/notes.md -o notes.pdf --resource-path=docs

Pandoc reads YAML front matter as the title and author, turns [^1] notes into real footnotes, typesets $...$ math and colors code blocks that name their language, none of which Zutilium's exporter does. For Chinese, Japanese or Korean text, use xelatex or lualatex and set an installed font with -V CJKmainfont=.

Which method to use

Method Best for Images Needs
Zutilium Markdown to PDF Quick PDFs, no setup Insert image A browser
VS Code + Markdown PDF Files in a code project Paths in the project VS Code and a Chromium browser
Pandoc Books, math, footnotes, scripts Relative paths Pandoc plus LaTeX or another engine

Zutilium offers two themes and two font styles but no custom CSS; for your own stylesheet, use VS Code's markdown-pdf.styles setting.

If the Markdown is already shown as a web page, such as a README on GitHub, your browser's print dialog (Ctrl+P or Command+P) can save it as a PDF, with the site's layout and little control over page breaks.

Troubleshooting Markdown to PDF problems

Images show as an "Image" placeholder

The image points to a file path or URL. Delete that line, put the cursor in its place and add the file with Insert image. README badges are remote images too: remove them or replace them with PNG copies (Insert image does not accept SVG).

HTML tags or \newpage appear in the PDF

Raw HTML is printed as text, so <br>, centered <p align="center"> logo blocks and HTML page breaks show up literally. Replace a <br> with a backslash at the end of the line, replace page-break code with <!-- pagebreak -->, and remove other tags.

The PDF starts with a line and a "title:" heading

That is YAML front matter, the block between two --- lines at the top of many documentation files. Zutilium does not read it as metadata. Delete the block and type the title into Document name instead.

Lines run together

Markdown joins lines that have no blank line between them into one paragraph. End a line with a backslash or two spaces for a hard line break, or leave a blank line to start a new paragraph.

The file will not open or the export stops

Each of these messages appears at the bottom of the workspace:

  • "Choose an .md, .markdown or .txt file." Rename it to .md, or paste the text.
  • "Could not read this file. Save it as UTF-8 Markdown and try again." Save it again as UTF-8.
  • "Inserted images must be at most 1 MiB. Compress the image first." Shrink or resize the picture.
  • "This insertion would exceed the 2 MiB Markdown limit." Use smaller images (see the budget above).
  • "The PDF exceeds 100 pages. Split the document into smaller files." Export the document in parts.
  • "PDF export took too long. Shorten the document or reduce its images and try again." Use fewer or smaller images, or split it.
  • "The PDF exporter is busy. Please try again shortly." Wait a moment and export again.

Chinese, Japanese, Korean or emoji characters look wrong

The bundled fonts cover Latin and Arabic script. Other scripts and emoji depend on fonts installed on Zutilium's server, and the editor warns you when your text contains them. Check the exported PDF closely, or use Pandoc with xelatex and a CJK font.

Frequently asked questions

Is the PDF searchable or just an image of the page?

It is real text. You can select, copy and search every word, code blocks included, and web links stay clickable. Some converters save each page as a picture, so test any PDF by selecting a sentence.

Can Pandoc convert Markdown to PDF without LaTeX?

Yes. Pass --pdf-engine=typst, or an HTML-based engine such as weasyprint or pagedjs-cli, after installing that program. LaTeX commands such as \newpage no longer apply, so use the engine's own page-break method.

How do I combine several Markdown files into one PDF?

In Zutilium, paste the files one after another into the editor with <!-- pagebreak --> between them, as long as the total stays within 2 MiB and 100 pages. With Pandoc, list the files in order: pandoc intro.md setup.md -o guide.pdf.

Can I convert the PDF back to Markdown?

PDF to MD extracts selectable text into Markdown with simple heading and list detection, but the formatting will not come back exactly. Keep the original .md file, or a copy from Download Markdown, for future edits.