Markdown2pdf

Data & APIs

Convert Markdown files to PDF or PNG with customizable professional themes and colored emoji support via CLI or API.

Install

openclaw skills install markdown2pdf

📄 Markdown2PDF Skill

A professional OpenClaw skill for converting Markdown documents to PDF and PNG with colored emoji support.


📋 Overview

PropertyValue
Namemarkdown2pdf
Version1.0.0
AuthorPocketAI for Leo
LicenseMIT
CategoryDocument Conversion
RepositoryGitHub

✨ Features

  • 📄 Markdown to PDF - Professional PDF document generation
  • 🖼️ Markdown to PNG - High-quality PNG image generation
  • 🎨 5 Professional Themes - default, dark, github, minimal, professional
  • 🌈 Colored Emoji Support - Automatic emoji to colored text label conversion
  • Custom CSS - Complete style control
  • 🚀 CLI & API - Multiple usage methods
  • 🧩 OpenClaw Integration - Seamless integration

🚀 Quick Start

Installation

cd ~/.openclaw/workspace/skills/markdown2pdf
pip3 install markdown pdfkit imgkit
brew install wkhtmltopdf  # macOS
# or
sudo apt-get install wkhtmltopdf  # Ubuntu

Basic Usage

# Convert to PDF
python3 src/converter.py input.md -f pdf

# Use theme
python3 src/converter.py README.md -t github -f pdf

# List themes
python3 src/converter.py --list-themes

🎨 Available Themes

ThemeDescriptionBest For
defaultModern clean designGeneral documents
darkDark themePresentations, night reading
githubGitHub-styleTechnical docs, README
minimalMinimalist designElegant documents
professionalBusiness styleReports, business docs

🌈 Colored Emoji Support

Automatically converts emoji to colored text labels for PDF compatibility:

EmojiConvertedColorMeaning
📊[数据]🔵 BlueData
📈[趋势↑]🟢 GreenGrowth
📉[趋势↓]🔴 RedDecline
[√]🟢 GreenSuccess
[×]🔴 RedError
⚠️[!]🟠 OrangeWarning
🚀[启动]🔴 RedLaunch
🟡 GoldStar

📖 API Usage

Python API

from src.converter import convert_markdown_to_pdf, MarkdownConverter

# Simple conversion
pdf_path = convert_markdown_to_pdf(
    markdown_text="# Hello World",
    output_filename="hello.pdf",
    theme="github"
)

# Advanced usage
converter = MarkdownConverter(
    output_dir=Path("./output"),
    theme="professional",
    custom_css=".custom { color: red; }"
)

pdf_path = converter.convert_to_pdf(
    markdown_text="# Document",
    output_filename="doc.pdf",
    page_size="A4",
    margin="15mm"
)

⚙️ Configuration

Default Settings

SettingValueDescription
default_themeprofessionalDefault theme for conversion
default_formats["pdf"]Default output formats
default_width1200Default PNG width in pixels
default_page_sizeA4Default PDF page size
default_margin20mmDefault PDF margin
emoji_supporttrueEnable emoji replacement
colored_emojitrueUse colored text labels

📦 Dependencies

PackageVersionPurpose
markdown>=3.5.0Markdown processing
pdfkit>=1.0.0PDF generation
imgkit>=1.2.3Image generation
wkhtmltopdf>=0.2.0HTML to PDF engine

📁 Project Structure

markdown2pdf/
├── src/
│   ├── converter.py          # Main converter
│   └── emoji_replacer.py     # Emoji conversion utility
├── output/                    # Output files
├── tests/
│   └── test_converter.py     # Test suite
├── README.md                  # Documentation
├── SKILL.md                   # This file
└── requirements.txt           # Dependencies

🧪 Testing

# Run tests
pytest tests/

# Test conversion
python3 src/converter.py test_document.md -t github -f pdf

📝 Changelog

v1.0.0 (2026-03-16)

Initial Stable Release

  • ✨ Markdown to PDF/PNG converter
  • 🎨 5 professional themes
  • 🌈 Colored emoji support
  • 🔧 CLI and API interfaces
  • 📚 Complete documentation
  • 🧩 OpenClaw integration

🎯 Use Cases

1. Investment Analysis Reports

python3 src/converter.py stock_analysis.md -t professional -f pdf

2. Technical Documentation

python3 src/converter.py README.md -t github -f pdf,png

3. Presentations

python3 src/converter.py presentation.md -t dark -f png --width 1920

4. Business Reports

python3 src/converter.py business_report.md -t professional -f pdf

📞 Support


📄 License

MIT License - See LICENSE file for details.


Happy Converting! 📄🎨


Last Updated: 2026-03-17
Version: 1.0.0
Author: PocketAI for Leo