Markdown to PDF¶
Convert Markdown files into styled PDF documents with optional custom CSS and table of contents.
Overview¶
The Markdown to PDF automation turns Markdown content into print-ready PDFs. It supports headings, lists, tables, code blocks, and optional syntax highlighting.
Key Features:
- Convert single files or entire directories
- Optional custom CSS styling
- Table of contents support
- Syntax highlighting for code blocks
- Preserves folder structure in batch mode
Quick Start¶
Run Instantly (No Installation)¶
Run Locally¶
Usage¶
Interactive Mode¶
Run without arguments for step-by-step prompts:
Command Line Mode¶
uv run r10n md2pdf \
--input ./docs/guide.md \
--output ./exports/guide.pdf \
--page-size A4 \
--syntax-highlight
Parameters¶
| Parameter | Short | Type | Required | Default | Description |
|---|---|---|---|---|---|
--input |
-i |
string | Yes | local/inputs/markdown |
Markdown file or directory |
--output |
-o |
string | No | Auto | Output PDF file or directory |
--css |
-c |
string | No | - | Custom CSS file |
--page-size |
- | string | No | A4 |
Page size (A4, Letter, Legal*) |
--toc |
- | flag | No | false |
Include table of contents |
--syntax-highlight |
- | flag | No | false |
Enable syntax highlighting |
--recursive |
-r |
flag | No | false |
Process subdirectories |
*Note: Legal currently falls back to A4 size.
Examples¶
Example 1: Convert a Single File¶
Example 2: Convert a Directory¶
Example 3: Apply Custom Styles¶
Input Format¶
Any Markdown file with standard syntax:
```Output¶
- Single file mode outputs a PDF next to the input file by default.
- Directory mode outputs PDFs into the provided output folder.
Configuration¶
No configuration file is required. Optional CSS files can be passed using --css.
Troubleshooting¶
Issue: Output not created - Cause: Input file path incorrect or missing. - Solution: Verify the path and file extension.
Issue: Styling not applied
- Cause: CSS file path not found.
- Solution: Provide a valid --css file path.