本文へスキップ

MarkdownをPDFに変換

.mdファイルをPDFに変換し、見出しはしおりとして残します。

お使いの端末で処理

このツールはブラウザーの中だけで動きます。ファイルがアップロードされることはなく、そのことはブラウザーのネットワークタブでご自身で確認できます。 ご自分で確かめてください。ブラウザーのネットワークタブを開いて見てください。残りの作業回数を尋ねる小さなリクエストが1つだけ表示されます。ツール名とハッシュだけで、ファイルは決して含まれません。

このツールでできること

This reads a Markdown file and lays it out as a PDF directly, without going through HTML on the way. Headings, lists, tables, block quotes, links and fenced code blocks all come across, and the headings also become a real PDF outline. Markdown has no pages of its own, so the pagination is created here rather than reproduced from anywhere - the paper size, margins and theme you pick are what decide where the breaks fall.

Use it when the reader has no Markdown reader: a README that has to go into a tender pack, meeting notes an editor wants as an attachment, a specification circulating for comment, or documentation you want on paper with a table of contents that works.

仕組み

  1. Drop your .md or .markdown files onto this page. Up to 20 at a time, each up to 50 MB.
  2. Pick a theme. Plain sets 11 pt with 1.45 line spacing, Book loosens to 11.5 pt and 1.6 for something read end to end, and Technical tightens to 10 pt and 1.35 for reference material that gets scanned rather than read.
  3. Choose the paper size, orientation and margins. Normal margins are 56 points on every side.
  4. Leave bookmarks from headings on so the finished PDF opens with a working outline, and turn page numbers off if the document already numbers itself.
  5. Under advanced options, decide whether YAML front matter at the top of the file should supply the document title.
  6. Press Convert. Each file becomes its own PDF and the downloads start on their own.

The parser walks Markdown into the document model directly and never renders it to HTML first. That sounds like an implementation detail and is not: a Markdown-to-HTML-to-PDF route escapes the content twice, and every escaping bug in that round trip shows up later as a stray ampersand or a visible line-break tag in somebody's finished document. Going straight to the model means the text you wrote is the text that gets measured.

Headings become the PDF outline, which is the thing that makes a long Markdown document usable as a PDF at all. A forty-page specification without an outline is a scroll bar and nothing else. One hash through six become outline entries at the matching depth, so the structure you already have in the file is the navigation the reader gets, with no extra step and nothing to maintain separately.

GitHub-flavoured extensions are on, so tables, strikethrough, task lists and bare URLs behave the way they do on GitHub rather than being left as literal punctuation. Fenced code blocks are set in Noto Sans Mono at 92 per cent of the body size, on a tinted wash, and a block longer than the remaining space is split across pages with the wash redrawn rather than being pushed whole onto the next sheet. Long code lines are folded, with the continuation indented to match the line it came from and the break preferred at a space so an identifier is not cut in half.

Images referenced by the Markdown are not embedded, and raw HTML blocks are not rendered. A Markdown file points at its pictures by path or by URL rather than containing them, and going out to fetch one would be exactly the outbound request this tool exists not to make. Convert the pictures separately with Images to PDF and join the results with Merge PDF if they need to be in the same document.

The Book theme asks for a serif face, and it is worth knowing what that gets you. With Embed a Unicode font on, which is the default, there is no Noto Serif in the embedded set, so serif borrows the sans faces and what you actually gain is the looser leading and the larger type. Turn embedding off and the text really is set in Times Roman, at the cost of every character outside the WinAnsi range.

このツールにできないこと

  • Images referenced by the Markdown are not embedded. Fetching them would mean an outbound request; convert them with Images to PDF and combine the results instead.
  • Raw HTML inside the Markdown is not rendered. Structure written as Markdown converts; structure written as HTML tags does not.

よくある質問

どの方言のMarkdownに対応していますか?
CommonMarkに加えて、GitHubの拡張、つまり表・打ち消し線・タスクリスト・リンクになる裸のURLに対応しています。見出し・番号付きと番号なしの箇条書き・入れ子の箇条書き・引用・水平線・インラインコード・コードブロックはすべて扱えます。ファイル冒頭のYAMLフロントマターは、その設定をオンにしていれば、表として印刷せずにドキュメントのタイトルとして読みます。
見出しは目次になりますか?
はい。「見出しからしおりを作る」をオンにすると、#1つから#6つまでが同じ階層のPDFのしおりになります。読む人は、ファイルにすでにある構造から作られたナビゲーションを手にします。Markdownに何かを足す必要も、手作業で同期を保つ必要もありません。
Markdownの中の画像が抜けているのはなぜですか?
Markdownファイルは画像を含んでいるのではなく参照しているだけで、それを取りに行けば、このページがあなたに代わって通信することになるからです。それは、ここのどのツールも拒んでいるただ一つのことです。テキスト・表・箇条書き・リンク・コードはすべて変換されます。画像も必要なら「画像をPDFに変換」に通してから、「PDFを結合」で2つのドキュメントを1つにしてください。
コードブロックはどのように組まれますか?
Noto Sans Monoで、本文の92パーセントの大きさ、薄い色を敷いた上に組まれます。タブは何かを測る前に空白4つへ展開されます。段の幅より長い行は切り落とさずに折り返し、続きは元の行に揃えて字下げされます。折る位置は空白を優先するので、長い識別子が途中で分断されません。
変換するためにドキュメントはアップロードされますか?
されません。ファイルのデコード・解析・レイアウトはブラウザーの中のWeb Workerで行われ、PDFもそこで書き出されます。このページが取りに行くのは、このサイト自身のオリジンにあるNotoのフォントだけです。一度ブラウザーがキャッシュしたあとは、接続を切ったままでも変換できます。

関連ツール