pdforge
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePDForge API (PDF Noodle)
PDForge API(PDF Noodle)
Use the PDForge API via direct calls to generate PDFs from templates or raw HTML.
curlOfficial docs:https://docs.pdforge.com/
Note: PDForge has been rebranded to PDF Noodle. Both and work.
api.pdforge.comapi.pdfnoodle.com通过直接调用使用PDForge API,从模板或原始HTML生成PDF。
curl官方文档:https://docs.pdforge.com/
注意:PDForge已更名为PDF Noodle。和均可使用。
api.pdforge.comapi.pdfnoodle.comWhen to Use
适用场景
Use this skill when you need to:
- Generate PDFs from reusable templates with dynamic data
- Convert HTML to PDF directly
- Create invoices, reports, or documents programmatically
- Export PNG images instead of PDFs
- Batch generate documents using async endpoints with webhooks
当你需要以下操作时,可使用此技能:
- 从可复用模板生成PDF并填充动态数据
- 直接将HTML转换为PDF
- 以编程方式创建发票、报告或文档
- 导出PNG图片而非PDF
- 批量生成文档:使用带webhook的异步端点
Prerequisites
前置条件
- Sign up at PDF Noodle (formerly PDForge)
- Go to the API Keys menu in the dashboard
- Copy your API key (format: )
pdfnoodle_api_xxxxx - Store it in the environment variable
PDFORGE_API_KEY
bash
export PDFORGE_API_KEY="pdfnoodle_api_your-key-here"Important: When usingin a command that pipes to another command, wrap the command containing$VARin$VAR. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.field'
- 在PDF Noodle(原PDForge)注册账号
- 进入控制台的API密钥菜单
- 复制你的API密钥(格式:)
pdfnoodle_api_xxxxx - 将其存储到环境变量中
PDFORGE_API_KEY
bash
export PDFORGE_API_KEY="pdfnoodle_api_your-key-here"重要提示: 当在包含管道的命令中使用时,需将包含$VAR的命令用$VAR包裹。由于Claude Code的bug,直接使用管道时环境变量会被静默清除。bash -c '...'bashbash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.field'
How to Use
使用方法
All examples below assume you have set.
PDFORGE_API_KEYBase URL:
https://api.pdfnoodle.com/v1以下所有示例均假设你已设置好。
PDFORGE_API_KEY基础URL:
https://api.pdfnoodle.com/v11. Generate PDF from Template (Sync)
1. 从模板同步生成PDF
Generate a PDF using a pre-built template with dynamic data.
Write to :
/tmp/pdforge_request.jsonjson
{
"templateId": "your-template-id",
"data": {
"name": "John Doe",
"date": "2025-01-15",
"items": [
{"description": "Item 1", "price": 100},
{"description": "Item 2", "price": 200}
]
}
}Then run:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'Response:
json
{
"signedUrl": "https://storage.googleapis.com/...",
"executionTime": 1234
}The is a temporary URL (expires in 1 hour) to download the generated PDF.
signedUrl使用预构建模板并填充动态数据生成PDF。
写入到:
/tmp/pdforge_request.jsonjson
{
"templateId": "your-template-id",
"data": {
"name": "John Doe",
"date": "2025-01-15",
"items": [
{"description": "Item 1", "price": 100},
{"description": "Item 2", "price": 200}
]
}
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'响应:
json
{
"signedUrl": "https://storage.googleapis.com/...",
"executionTime": 1234
}signedUrl2. Generate PDF from Template (Async)
2. 从模板异步生成PDF
For batch processing, use the async endpoint with a webhook.
Write to :
/tmp/pdforge_request.jsonjson
{
"templateId": "your-template-id",
"webhook": "https://your-server.com/webhook",
"data": {
"name": "Jane Doe",
"amount": 500
}
}Then run:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/pdf/async" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'Response:
json
{
"requestId": "abc123"
}The webhook will receive the when generation is complete.
signedUrl对于批量处理,使用带webhook的异步端点。
写入到:
/tmp/pdforge_request.jsonjson
{
"templateId": "your-template-id",
"webhook": "https://your-server.com/webhook",
"data": {
"name": "Jane Doe",
"amount": 500
}
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/pdf/async" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'响应:
json
{
"requestId": "abc123"
}生成完成后,webhook将收到。
signedUrl3. Convert HTML to PDF (Sync)
3. 同步将HTML转换为PDF
Convert raw HTML directly to PDF without a template.
Write to :
/tmp/pdforge_request.jsonjson
{
"html": "<html><body><h1>Hello World</h1><p>This is a PDF generated from HTML.</p></body></html>"
}Then run:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/html-to-pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'无需模板,直接将原始HTML转换为PDF。
写入到:
/tmp/pdforge_request.jsonjson
{
"html": "<html><body><h1>Hello World</h1><p>This is a PDF generated from HTML.</p></body></html>"
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/html-to-pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'4. Convert HTML to PDF with Styling
4. 带样式的HTML转PDF
Include CSS for styled PDFs.
Write to :
/tmp/pdforge_request.jsonjson
{
"html": "<html><head><style>body { font-family: Arial; } h1 { color: #333; } .invoice { border: 1px solid #ddd; padding: 20px; }</style></head><body><div class=\"invoice\"><h1>Invoice #001</h1><p>Amount: $500</p></div></body></html>"
}Then run:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/html-to-pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'包含CSS以生成带样式的PDF。
写入到:
/tmp/pdforge_request.jsonjson
{
"html": "<html><head><style>body { font-family: Arial; } h1 { color: #333; } .invoice { border: 1px solid #ddd; padding: 20px; }</style></head><body><div class=\"invoice\"><h1>Invoice #001</h1><p>Amount: $500</p></div></body></html>"
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/html-to-pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'5. Generate PNG Instead of PDF
5. 生成PNG而非PDF
Set to true to get a PNG.
convertToImageWrite to :
/tmp/pdforge_request.jsonjson
{
"html": "<html><body><h1>Image Export</h1></body></html>",
"convertToImage": true
}Then run:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/html-to-pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'将设为true即可获取PNG图片。
convertToImage写入到:
/tmp/pdforge_request.jsonjson
{
"html": "<html><body><h1>Image Export</h1></body></html>",
"convertToImage": true
}然后运行:
bash
bash -c 'curl -s -X POST "https://api.pdfnoodle.com/v1/html-to-pdf/sync" --header "Authorization: Bearer ${PDFORGE_API_KEY}" --header "Content-Type: application/json" -d @/tmp/pdforge_request.json'6. Download Generated PDF
6. 下载生成的PDF
After getting the , download the PDF:
signedUrlReplace with the actual signed URL from the previous response:
<your-signed-url>bash
curl -s -o output.pdf "https://storage.googleapis.com/<your-signed-url>"获取后,下载PDF:
signedUrl将替换为之前响应中的实际临时URL:
<your-signed-url>bash
curl -s -o output.pdf "https://storage.googleapis.com/<your-signed-url>"Request Parameters
请求参数
Template Endpoint Parameters
模板端点参数
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | Template ID from dashboard |
| object | Yes | Variables for the template |
| string | Async only | Webhook URL for delivery |
| boolean | No | Return PNG instead of PDF |
| object | No | PDF metadata (title, author, etc.) |
| boolean | No | Hide header/footer on first page |
| boolean | No | Enable debug mode |
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 是 | 控制台中的模板ID |
| object | 是 | 模板所需的变量数据 |
| string | 仅异步 | 用于接收结果的Webhook URL |
| boolean | 否 | 返回PNG而非PDF |
| object | 否 | PDF元数据(标题、作者等) |
| boolean | 否 | 隐藏第一页的页眉/页脚 |
| boolean | 否 | 启用调试模式 |
HTML Endpoint Parameters
HTML端点参数
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | Yes | HTML content to convert |
| boolean | No | Return PNG instead of PDF |
| object | No | PDF metadata settings |
| object | No | PDF generation options |
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 是 | 待转换的HTML内容 |
| boolean | 否 | 返回PNG而非PDF |
| object | 否 | PDF元数据设置 |
| object | 否 | PDF生成选项 |
Metadata Object
元数据对象
json
{
"metadata": {
"title": "Invoice #001",
"author": "Company Name",
"subject": "Monthly Invoice",
"keywords": ["invoice", "payment"]
}
}json
{
"metadata": {
"title": "Invoice #001",
"author": "Company Name",
"subject": "Monthly Invoice",
"keywords": ["invoice", "payment"]
}
}Guidelines
指南
- Use templates for reusable documents: Create templates in the dashboard for invoices, reports, etc.
- Use HTML endpoint for one-off documents: When you don't need a reusable template
- Use async for batch processing: Async endpoint is better for generating many PDFs
- Download promptly: Signed URLs expire in 1 hour
- Include CSS inline: For HTML to PDF, include all styles in the HTML
- 使用模板处理可复用文档:在控制台中创建发票、报告等模板
- 使用HTML端点处理一次性文档:当你不需要可复用模板时
- 使用异步端点进行批量处理:异步端点更适合生成大量PDF
- 及时下载:临时URL1小时后过期
- 内联CSS样式:HTML转PDF时,需将所有样式包含在HTML中