markdown-to-pdf
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemarkdown-to-pdf
markdown-to-pdf
Convert markdown files to professionally-styled PDF documents.
将Markdown文件转换为具有专业样式的PDF文档。
Installation Required
需要安装
bash
cd .claude/skills/markdown-to-pdf
npm installDependencies: (includes Puppeteer, auto-downloads Chromium ~200MB)
md-to-pdfbash
cd .claude/skills/markdown-to-pdf
npm install依赖项: (包含Puppeteer,会自动下载约200MB的Chromium)
md-to-pdfQuick Start
快速开始
bash
undefinedbash
undefinedBasic conversion
基础转换
node .claude/skills/markdown-to-pdf/scripts/convert.cjs
--file ./README.md
--file ./README.md
node .claude/skills/markdown-to-pdf/scripts/convert.cjs
--file ./README.md
--file ./README.md
Custom output path
自定义输出路径
node .claude/skills/markdown-to-pdf/scripts/convert.cjs
--file ./doc.md
--output ./output/doc.pdf
--file ./doc.md
--output ./output/doc.pdf
node .claude/skills/markdown-to-pdf/scripts/convert.cjs
--file ./doc.md
--output ./output/doc.pdf
--file ./doc.md
--output ./output/doc.pdf
Custom styling
自定义样式
node .claude/skills/markdown-to-pdf/scripts/convert.cjs
--file ./report.md
--style ./custom-style.css
--file ./report.md
--style ./custom-style.css
undefinednode .claude/skills/markdown-to-pdf/scripts/convert.cjs
--file ./report.md
--style ./custom-style.css
--file ./report.md
--style ./custom-style.css
undefinedCLI Options
CLI选项
| Option | Required | Description |
|---|---|---|
| Yes | Input markdown file |
| No | Output PDF path (default: input name + .pdf) |
| No | Custom CSS file |
| 选项 | 是否必填 | 描述 |
|---|---|---|
| 是 | 输入的Markdown文件路径 |
| 否 | 输出PDF的路径(默认:输入文件名 + .pdf) |
| 否 | 自定义CSS文件路径 |
Output Format (JSON)
输出格式(JSON)
json
{
"success": true,
"input": "/path/to/input.md",
"output": "/path/to/output.pdf",
"pages": 5
}json
{
"success": true,
"input": "/path/to/input.md",
"output": "/path/to/output.pdf",
"pages": 5
}Default Styling
默认样式
- GitHub-flavored markdown
- Code syntax highlighting (highlight.js)
- Sans-serif body (system fonts)
- Monospace code blocks
- A4 page size, 2cm margins
- GitHub风格的Markdown
- 代码语法高亮(highlight.js)
- 无衬线正文(系统字体)
- 等宽代码块
- A4页面尺寸,2cm边距
Customization
自定义设置
Create custom CSS:
css
body {
font-family: Georgia, serif;
font-size: 12pt;
line-height: 1.6;
}
h1 { color: #2c3e50; border-bottom: 2px solid #3498db; }
code { background: #f4f4f4; padding: 2px 6px; }创建自定义CSS:
css
body {
font-family: Georgia, serif;
font-size: 12pt;
line-height: 1.6;
}
h1 { color: #2c3e50; border-bottom: 2px solid #3498db; }
code { background: #f4f4f4; padding: 2px 6px; }Troubleshooting
故障排除
Chromium download fails: Set then manually install Chrome
Memory issues: Large docs may need
PUPPETEER_SKIP_DOWNLOAD=1--max-old-space-size=4096Chromium下载失败: 设置环境变量,然后手动安装Chrome
内存问题: 大型文档可能需要添加参数
PUPPETEER_SKIP_DOWNLOAD=1--max-old-space-size=4096IMPORTANT Task Planning Notes
重要任务规划说明
- Always plan and break many small todo tasks
- Always add a final review todo task to review the works done at the end to find any fix or enhancement needed
- 始终规划并拆分多个小型待办任务
- 始终添加一个最终审核的待办任务,在最后检查已完成的工作,找出需要修复或优化的地方