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.
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install zl-md-to-pdf - After installation, invoke the skill by name or use
/zl-md-to-pdf - Provide required inputs per the skill's parameter spec and get structured output
What is md-to-pdf?
Use when converting markdown files to PDF with styling, code highlighting, and CJK support. It is an AI Agent Skill for Claude Code / OpenClaw, with 51 downloads so far.
How do I install md-to-pdf?
Run "/install zl-md-to-pdf" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is md-to-pdf free?
Yes, md-to-pdf is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does md-to-pdf support?
md-to-pdf is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created md-to-pdf?
It is built and maintained by zhuleiKiro222 (@zhuleikiro222); the current version is v1.0.0.