Skip to content

gewenbo888/md2pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

md2pdf

Convert Markdown files to beautifully styled PDFs. Supports multiple themes, custom margins, and page formats.

Includes a Claude Code skill so AI assistants can convert Markdown to PDF directly.

Quick Start

# Using npx (no install needed)
npx md2pdf README.md

# Or install globally
npm install -g md2pdf
md2pdf document.md

Options

md2pdf <input.md> [options]

Options:
  -o, --output <path>     Output PDF path (default: same name as input)
  -t, --theme <name>      Theme: default, dark, minimal
  -m, --margin <size>     Page margin (default: 20mm)
  -f, --format <size>     Page format: A4, Letter, A3
  -h, --help              Show help

Themes

Default

Clean sans-serif typography with GitHub-style code blocks. Best for general documents.

md2pdf document.md

Dark

Dark background with light text. Ideal for technical documentation.

md2pdf document.md -t dark

Minimal

Serif typography (Georgia) with wider line-height and narrow column. Best for prose-heavy documents.

md2pdf document.md -t minimal

Programmatic Usage

const { convert } = require('md2pdf');

await convert('document.md', {
  output: 'output.pdf',
  theme: 'dark',
  margin: '25mm',
  format: 'A4',
});

Claude Code Skill

This project includes a Claude Code skill that allows AI assistants to convert Markdown files to PDF.

Install as a Claude Code plugin

# Clone to your plugins directory
git clone https://github.com/gewenbo888/md2pdf.git ~/.claude/plugins/md2pdf

# Or copy the skill to your skills directory
cp -r md2pdf/skills/md2pdf ~/.claude/skills/md2pdf

Install as a personal skill only

mkdir -p ~/.claude/skills/md2pdf
cp skills/md2pdf/SKILL.md ~/.claude/skills/md2pdf/SKILL.md

Once installed, you can ask Claude Code:

  • "Convert this markdown to PDF"
  • "Make a PDF from README.md with dark theme"
  • "Export all .md files as PDFs"

Examples

# Basic conversion
md2pdf README.md

# Custom output path and theme
md2pdf report.md -o ~/Desktop/report.pdf -t dark

# Letter format with wider margins
md2pdf essay.md -f Letter -m 25mm -t minimal

# Convert all markdown files in a directory
for f in docs/*.md; do md2pdf "$f"; done

License

MIT

About

Convert Markdown to PDF with beautiful themes. Includes Claude Code skill for AI-powered usage.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors