Markdown to PDF with a live paginated preview.
🌐 moon-jam.me/md2pdf — runs entirely in the browser
English | 繁體中文
md2pdf-demo.mp4
The key difference: preview shows real PDF pagination with actual margins, not just styled HTML. Code blocks stay intact across page boundaries. What you see is what you export.
Built on Paged.js for live preview layout, Vivliostyle for CLI PDF generation, Prism.js (Catppuccin Mocha) for syntax highlighting, and Noto fonts for Chinese typography.
moon-jam.me/md2pdf — no install needed.
Pure frontend: your content stays in your browser, with no server upload.
- Live paginated preview updates as you type
- Open a local folder to resolve relative image paths without any upload
- Paste or drag images straight into the editor
- Resize images inline with
{width=300}or{width=50% height=auto} - Custom CSS panel with live preview
<!-- pagebreak -->to force page breaks- Title field at the top sets the PDF filename
- Autosaves locally in your browser via IndexedDB
For local use or scripting.
CLI output is powered by Vivliostyle.
Requirements: Node.js 18+
git clone https://github.com/moon-jam/md2pdf.git
cd md2pdf
npm install && npm link# basic usage
md2pdf report.md
# watch mode (live preview in browser, auto-reloads on save)
md2pdf report.md --watch
# custom output path
md2pdf report.md -o ~/Documents/final.pdf
# change paper size
md2pdf report.md --size Letter
# custom stylesheet
md2pdf report.md --style my_theme.cssGenerated from this repository:
- README.pdf (from
md2pdf README.md -p) - README.zh-TW.pdf (from
md2pdf README.zh-TW.md -p)
| Flag | Alias | Description | Default |
|---|---|---|---|
--output |
-o |
Output path | Same dir, .pdf extension |
--watch |
-w |
Live preview in browser | false |
--style |
CSS file | Bundled style.css |
|
--size |
Paper size | A4 |
|
--title |
PDF title | Filename | |
--language |
Language metadata | zh-TW |
|
--page-numbers |
-p |
Page numbers in footer | false |
The bundled style.css controls everything: fonts, spacing, syntax highlight colours, page layout. Edit it directly and re-run.
MIT · moon-jam