Markdown、GFM和自定义CSS
将Markdown转换为 精美PDF
将Markdown文档转换为专业样式的PDF。完整支持GitHub Flavored Markdown,包含表格、代码块、任务列表和自定义CSS样式。
# Convert Markdown to PDF
curl -X POST \
https://api.convertfilefast.com/v2/convert/markdown-to-pdf \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"content": "# Project Report\n\n## Summary\n\n| Metric | Value |\n|--------|-------|\n| Users | 1,234 |",
"css": "body { font-family: Georgia, serif; line-height: 1.6; }",
"options": {"page_size": "A4"}
}' \
--output report.pdf
# HTTP 200 OK — Content-Type: application/pdfimport requests
markdown_content = """
# Monthly Report
## Key Metrics
| Metric | Value |
|--------|-------|
| Users | 1,234 |
| Revenue | $56K |
"""
response = requests.post(
"https://api.convertfilefast.com/v2/convert/markdown-to-pdf",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"content": markdown_content, "options": {"page_size": "A4"} }
)
with open("report.pdf", "wb") as f:
f.write(response.content)const markdown = `# Monthly Report\n\n## Key Metrics\n| Metric | Value |\n|--------|-------|\n| Users | 1,234 |`;
const response = await fetch(
"https://api.convertfilefast.com/v2/convert/markdown-to-pdf",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({ content: markdown, options: { page_size: "A4" } }),
}
);
fs.writeFileSync("report.pdf", Buffer.from(await response.arrayBuffer()));// n8n HTTP Request Node
{
"method": "POST",
"url": "https://api.convertfilefast.com/v2/convert/markdown-to-pdf",
"contentType": "json",
"body": "={{ JSON.stringify({ content: $json.markdown_text, options: { page_size: 'A4' } }) }}",
"options": { "response": { "responseFormat": "file" } }
}2秒内转换完成
优势
为什么使用我们的API?
完整可靠的解决方案,适用于任何技术栈的集成。
GitHub Flavored Markdown
完整GFM支持:表格、任务列表、删除线、带语法高亮的代码块。
自定义CSS样式
应用自己的CSS控制输出PDF的字体、颜色、间距和布局。
多种输入方式
发送原始Markdown字符串、上传.md文件或从URL获取。
代码块渲染
带语法高亮的代码块在PDF输出中完美保留格式。
页面配置
设置页面大小、方向和边距,输出专业文档。
批量处理
使用n8n或脚本在自动化工作流中转换多个Markdown文件。
面向 AI 智能体
也可以从 Claude、Cursor 或任意 MCP 客户端调用
Convert File Fast 提供原生的 Model Context Protocol 服务器。只需一次工具调用,即可把该转换交给 AI 智能体完成 —— 无需 HTTP 客户端,无需处理二进制,并为每个用户单独签发 API 密钥。
本地安装
npx -y convertfilefast-mcpMCP 工具调用
convert_file({ target_format: "pdf", source_url: "https://example.com/file.md" })