HTML and Markdown to PDF

Turn Markdown or HTML into a PDF with real, selectable text in any language, on the paper size and margins you choose.

loading HTML and Markdown to PDF
About this tool

What does an HTML and Markdown to PDF converter do?

It turns a text written in Markdown, or a page written in HTML, into a PDF you can send, print or archive. Markdown is the light format of README files, notes, documentation and chat tools: # for headings, - for lists, pipes for tables, backticks for code. HTML is what web pages, e-mail templates and many report generators produce. Both are easy to write and awkward to share with someone who just wants a document.

This converter lays the text out as pages on the paper you choose (A4, Letter, Legal, A3 or A5), in portrait or landscape, with the margins you want. The PDF keeps real text: you can select it, search it, copy it and a screen reader can read it. Accented letters, Greek, Cyrillic, Chinese, Japanese, Korean and Arabic come out right, because the page is drawn by your browser's own print engine with the fonts installed on your device.

Everything happens on this page. The text is never uploaded, and the page it is printed from is locked down: scripts, event handlers and forms are removed before anything is shown, and pictures from other sites are left out, because the tool never goes online.

How to convert Markdown or HTML to PDF

  1. Open the page. A sample report in Markdown is already loaded, with a list, a table, code and text in several scripts, so you can see the result at once.
  2. Choose Markdown or HTML above the editor, then paste your text, type it, or drop a .md, .txt or .html file on the page.
  3. Watch the preview on the right. It shows the page at the width of the printable area, a dashed line where each new page starts and an estimate of the number of pages.
  4. Set the paper size, the orientation and the margins. For Markdown you can also pick the text size and start a new page at every top-level heading.
  5. Check the file name under Output. It comes from the first heading or the HTML title, and you can change it.
  6. Press Save as PDF. The print window of your browser opens: choose Save as PDF (or Microsoft Print to PDF on Windows) as the destination and save. Turning off Headers and footers in that window removes the date and address the browser would add.

Examples

A README as a handout

Paste the README of a project in Markdown mode, choose A4 portrait and normal margins. Headings get a thin rule, code blocks keep their monospaced font and wrap instead of running off the page, and tables get borders. To keep the installation section on its own page, put this line right before it:

<!-- pagebreak -->

An HTML invoice from a template

Switch to HTML and paste the whole document, with its <style> block. The page's own CSS is kept, so the invoice looks as designed. The tool only adds the paper and the margins. Turn on Print backgrounds and colors if the invoice has a shaded header: browsers drop backgrounds when printing unless asked to keep them.

A wide table in landscape

A spreadsheet exported as an HTML table may be wider than A4 portrait. Switch to landscape, pick narrow margins, and watch the preview until the last column fits.

Notes in Japanese and Portuguese

A text such as 会議のメモ – Ação para sexta is printed with the fonts your system has for each script, as selectable text, not as a picture.

Common errors and limits

  • Looking for a download button. The PDF is written by the browser's print engine, so it is saved from the print window. That is what keeps the text selectable in every language. Choose Save as PDF as the printer.
  • Pictures that disappear. Images linked from other sites (https://…) are left out, and a note says how many. Embed them as data: addresses, or convert the file with another tool that is allowed online.
  • Date and URL at the top of each page. That is the browser's own header. Turn off Headers and footers in the print window.
  • A different look in another browser. Chrome, Edge, Firefox and Safari each have their own print engine. Paper size and margins are honoured everywhere current; fonts and page breaks can differ by a line or two.
  • Phones. On iPhone and iPad, Safari may print the whole tool page instead of just the document. Use a desktop browser, or Chrome on Android, for a clean result.
  • Scripts in the HTML. They never run here. A page that builds its content with JavaScript, such as a chart drawn by a script, comes out empty where that content would be.

Frequently asked questions

Is the text in the PDF selectable?

Yes. The print engine writes real text with embedded fonts, so you can select, search and copy it, unlike converters that take a screenshot of the page.

Does it work with Chinese, Japanese or Arabic text?

Yes, as long as your device has a font for that script, which every current system does. The browser picks the font and embeds it in the PDF.

Is my document uploaded anywhere?

No. The conversion happens in this browser tab. The preview and the printed page are blocked from loading anything from the network.

How do I force a page break?

Write <!-- pagebreak --> on its own line, in Markdown or in HTML. In Markdown mode you can also start every top-level heading on a new page.

Can I turn the PDF back into text or Markdown?

Use PDF to text to extract the text again, or Markdown to HTML if you only need the HTML of your Markdown. To join several PDFs into one, use Merge PDF.

Report a problem