Markdown2pdf

👤 leohuang8688 📦 v2.1.2 ⭐ 4.3 ⬇️ 928 下载
📄 办公效率 免费

📖 技能介绍

📄 Markdown2PDF Skill

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


📋 Overview

Property Value
Name markdown2pdf
Version 1.0.0
Author PocketAI for Leo
License MIT
Category Document Conversion
Repository GitHub

✨ Features

  • 📄 Markdown to PDF - Professional PDF document generation

    这个技能的最新版本可以在7w4.net小葱技能站找到。

  • 🖼️ 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

Theme Description Best For
default Modern clean design General documents
dark Dark theme Presentations, night reading
github GitHub-style Technical docs, README
minimal Minimalist design Elegant documents
professional Business style Reports, business docs

🌈 Colored Emoji Support

Automatically converts emoji to colored text labels for PDF compatibility:

Emoji Converted Color Meaning
📊 [数据] 🔵 Blue Data
📈 [趋势↑] 🟢 Green Growth
📉 [趋势↓] 🔴 Red Decline
[√] 🟢 Green Success
[×] 🔴 Red Error
⚠️ [!] 🟠 Orange Warning
🚀 [启动] 🔴 Red Launch
🟡 Gold Star

📖 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

Setting Value Description
default_theme professional Default theme for conversion
default_formats ["pdf"] Default output formats
default_width 1200 Default PNG width in pixels
default_page_size A4 Default PDF page size
default_margin 20mm Default PDF margin
emoji_support true Enable emoji replacement
colored_emoji true Use colored text labels

📦 Dependencies

Package Version Purpose
markdown >=3.5.0 Markdown processing
pdfkit >=1.0.0 PDF generation
imgkit >=1.2.3 Image generation
wkhtmltopdf >=0.2.0 HTML 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

🤖 AI 评测

这个Skill质量不错,功能简单实用。文档写得很清晰,主题风格多样可选,彩色emoji是一大亮点。安装稍微麻烦点,需要额外装wkhtmltopdf软件,但按说明操作就行。转换效果专业,支持命令行和代码调用两种方式,小白也能快速上手。对于需要把Markdown文档转成漂亮PDF的用户来说,这是一个值得一试的工具。

📊 多维度评分

适应性4.2
规范性4.3
有效性4.4
可靠性4
可信度5

📁 包含文件 (17 个)

📄 CHANGELOG.md 2.3 KB
📄 INSTALL.md 4.6 KB
📄 README.md 10.4 KB
📄 SKILL.md 5.2 KB
📄 _meta.json 131 B
📄 install.sh 1.3 KB
📄 output/HSTECH_analysis.md 12.6 KB
📄 output/install_guide.md 3 KB
📄 output/sanhua_analysis.md 16.8 KB
📄 output/sanhua_real_analysis.md 10.7 KB
📄 pyproject.toml 573 B
📄 requirements.txt 63 B
📄 src/converter.py 26.2 KB
📄 src/emoji_replacer.py 3.5 KB
📄 test_document.md 1.6 KB
📄 test_quick.py 2.1 KB
📄 tests/test_converter.py 7.6 KB