md-to-pdf
/install zl-md-to-pdf
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
.mdfile 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 [email protected] [email protected]
Then copy the convert.js script from this skill's directory.
Features
| Feature | Support |
|---|---|
| Headings (H1-H6) | Styled with hierarchy |
| Code blocks | Syntax highlighting via highlight.js |
| Tables | Bordered with zebra striping |
| Lists | Bulleted and numbered |
| Images | Embedded (relative paths resolved) |
| Links | Clickable in PDF |
| CJK/Chinese | Full support |
| Page numbers | Bottom center by default |
Customization
Edit the CSS in convert.js to customize:
- Font: Change
font-familyinbodystyle - Colors: Modify
colorandbackgroundvalues - Margins: Adjust
--marginTop,--marginBottom, etc. in options - Code theme: Change
preandcodebackground colors
Common Issues
| Issue | Solution |
|---|---|
| Browser not found | Set CHROME_PATH or EDGE_PATH environment variable |
| Permission denied | Use Edge instead of Chrome, or run with elevated permissions |
| ESM module errors | Use [email protected] and [email protected] (CommonJS compatible) |
| Large file timeout | Increase timeout in page.setContent() options |
Implementation
The conversion script uses:
- marked - Parse markdown to HTML
- puppeteer-core - Launch headless browser to render HTML
- Page.pdf() - Generate PDF from rendered page
See convert.js in this skill directory for the complete implementation.
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install zl-md-to-pdf - 安装完成后,直接呼叫该 Skill 的名称或使用
/zl-md-to-pdf触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
md-to-pdf 是什么?
Use when converting markdown files to PDF with styling, code highlighting, and CJK support. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 51 次。
如何安装 md-to-pdf?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install zl-md-to-pdf」即可一键安装,无需额外配置。
md-to-pdf 是免费的吗?
是的,md-to-pdf 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
md-to-pdf 支持哪些平台?
md-to-pdf 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 md-to-pdf?
由 zhuleiKiro222(@zhuleikiro222)开发并维护,当前版本 v1.0.0。