← 返回
未分类 中文

md-to-pdf

Use when converting markdown files to PDF with styling, code highlighting, and CJK support
用于将 Markdown 文件转换为 PDF,支持样式、代码高亮和 CJK 支持
zhuleikiro222 zhuleikiro222 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 1
Stars
📥 129
下载
💾 0
安装
1
版本
#latest

概述

MD to PDF Conversion

Overview

Converts markdown files to styled PDF documents using Node.js, marked, and puppeteer-core. Supports Chinese/CJK text, code syntax highlighting, tables, and images.

When to Use

  • User asks to convert a .md file to PDF
  • Need to generate a printable document from markdown
  • Creating offline documentation or reports
  • Sharing formatted technical documents

Prerequisites

  • Node.js installed (v18+ recommended)
  • Google Chrome or Microsoft Edge browser installed

Quick Start

# Convert a markdown file to PDF
node convert.js input.md

# Specify output file
node convert.js input.md output.pdf

# Without page numbers
node convert.js input.md --no-page-numbers

Installation

First-time setup in the target project directory:

mkdir -p .md-to-pdf-tool && cd .md-to-pdf-tool
npm init -y
npm install marked@4.3.0 puppeteer-core@19.11.1

Then copy the convert.js script from this skill's directory.

Features

FeatureSupport
------------------
Headings (H1-H6)Styled with hierarchy
Code blocksSyntax highlighting via highlight.js
TablesBordered with zebra striping
ListsBulleted and numbered
ImagesEmbedded (relative paths resolved)
LinksClickable in PDF
CJK/ChineseFull support
Page numbersBottom center by default

Customization

Edit the CSS in convert.js to customize:

  • Font: Change font-family in body style
  • Colors: Modify color and background values
  • Margins: Adjust --marginTop, --marginBottom, etc. in options
  • Code theme: Change pre and code background colors

Common Issues

IssueSolution
-----------------
Browser not foundSet CHROME_PATH or EDGE_PATH environment variable
Permission deniedUse Edge instead of Chrome, or run with elevated permissions
ESM module errorsUse marked@4.3.0 and puppeteer-core@19.11.1 (CommonJS compatible)
Large file timeoutIncrease timeout in page.setContent() options

Implementation

The conversion script uses:

  1. marked - Parse markdown to HTML
  2. puppeteer-core - Launch headless browser to render HTML
  3. Page.pdf() - Generate PDF from rendered page

See convert.js in this skill directory for the complete implementation.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-06-04 13:58

安全检测

腾讯云安全 (Keen)

队列中

腾讯云安全 (Sanbu)

队列中

🔗 相关推荐

office-efficiency

Gog

steipete
Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。
★ 932 📥 187,282
office-efficiency

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 387 📥 147,145
office-efficiency

Nano Pdf

steipete
使用nano-pdf CLI通过自然语言指令编辑PDF
★ 279 📥 116,750