pdforge

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

PDForge API (PDF Noodle)

PDForge API(PDF Noodle)

Use the PDForge API via direct
curl
calls to generate PDFs from templates or raw HTML.
Official docs:
https://docs.pdforge.com/
Note: PDForge has been rebranded to PDF Noodle. Both
api.pdforge.com
and
api.pdfnoodle.com
work.

通过直接调用
curl
使用PDForge API,从模板或原始HTML生成PDF
官方文档:
https://docs.pdforge.com/
注意:PDForge已更名为PDF Noodle。
api.pdforge.com
api.pdfnoodle.com
均可使用。

When 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

前置条件

  1. Sign up at PDF Noodle (formerly PDForge)
  2. Go to the API Keys menu in the dashboard
  3. Copy your API key (format:
    pdfnoodle_api_xxxxx
    )
  4. Store it in the environment variable
    PDFORGE_API_KEY
bash
export PDFORGE_API_KEY="pdfnoodle_api_your-key-here"

Important: When using
$VAR
in a command that pipes to another command, wrap the command containing
$VAR
in
bash -c '...'
. Due to a Claude Code bug, environment variables are silently cleared when pipes are used directly.
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.field'
  1. PDF Noodle(原PDForge)注册账号
  2. 进入控制台的API密钥菜单
  3. 复制你的API密钥(格式:
    pdfnoodle_api_xxxxx
  4. 将其存储到环境变量
    PDFORGE_API_KEY
bash
export PDFORGE_API_KEY="pdfnoodle_api_your-key-here"

重要提示: 当在包含管道的命令中使用
$VAR
时,需将包含
$VAR
的命令用
bash -c '...'
包裹。由于Claude Code的bug,直接使用管道时环境变量会被静默清除。
bash
bash -c 'curl -s "https://api.example.com" -H "Authorization: Bearer $API_KEY"' | jq '.field'

How to Use

使用方法

All examples below assume you have
PDFORGE_API_KEY
set.
Base URL:
https://api.pdfnoodle.com/v1

以下所有示例均假设你已设置好
PDFORGE_API_KEY
基础URL:
https://api.pdfnoodle.com/v1

1. Generate PDF from Template (Sync)

1. 从模板同步生成PDF

Generate a PDF using a pre-built template with dynamic data.
Write to
/tmp/pdforge_request.json
:
json
{
  "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
signedUrl
is a temporary URL (expires in 1 hour) to download the generated PDF.

使用预构建模板并填充动态数据生成PDF。
写入到
/tmp/pdforge_request.json
json
{
  "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
}
signedUrl
是临时URL(1小时后过期),用于下载生成的PDF。

2. Generate PDF from Template (Async)

2. 从模板异步生成PDF

For batch processing, use the async endpoint with a webhook.
Write to
/tmp/pdforge_request.json
:
json
{
  "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
signedUrl
when generation is complete.

对于批量处理,使用带webhook的异步端点。
写入到
/tmp/pdforge_request.json
json
{
  "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将收到
signedUrl

3. Convert HTML to PDF (Sync)

3. 同步将HTML转换为PDF

Convert raw HTML directly to PDF without a template.
Write to
/tmp/pdforge_request.json
:
json
{
  "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.json
json
{
  "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.json
:
json
{
  "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.json
json
{
  "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
convertToImage
to true to get a PNG.
Write to
/tmp/pdforge_request.json
:
json
{
  "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'

convertToImage
设为true即可获取PNG图片。
写入到
/tmp/pdforge_request.json
json
{
  "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
signedUrl
, download the PDF:
Replace
<your-signed-url>
with the actual signed URL from the previous response:
bash
curl -s -o output.pdf "https://storage.googleapis.com/<your-signed-url>"

获取
signedUrl
后,下载PDF:
<your-signed-url>
替换为之前响应中的实际临时URL:
bash
curl -s -o output.pdf "https://storage.googleapis.com/<your-signed-url>"

Request Parameters

请求参数

Template Endpoint Parameters

模板端点参数

ParameterTypeRequiredDescription
templateId
stringYesTemplate ID from dashboard
data
objectYesVariables for the template
webhook
stringAsync onlyWebhook URL for delivery
convertToImage
booleanNoReturn PNG instead of PDF
metadata
objectNoPDF metadata (title, author, etc.)
hasCover
booleanNoHide header/footer on first page
debug
booleanNoEnable debug mode
参数类型是否必填描述
templateId
string控制台中的模板ID
data
object模板所需的变量数据
webhook
string仅异步用于接收结果的Webhook URL
convertToImage
boolean返回PNG而非PDF
metadata
objectPDF元数据(标题、作者等)
hasCover
boolean隐藏第一页的页眉/页脚
debug
boolean启用调试模式

HTML Endpoint Parameters

HTML端点参数

ParameterTypeRequiredDescription
html
stringYesHTML content to convert
convertToImage
booleanNoReturn PNG instead of PDF
metadata
objectNoPDF metadata settings
pdfParams
objectNoPDF generation options
参数类型是否必填描述
html
string待转换的HTML内容
convertToImage
boolean返回PNG而非PDF
metadata
objectPDF元数据设置
pdfParams
objectPDF生成选项

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

指南

  1. Use templates for reusable documents: Create templates in the dashboard for invoices, reports, etc.
  2. Use HTML endpoint for one-off documents: When you don't need a reusable template
  3. Use async for batch processing: Async endpoint is better for generating many PDFs
  4. Download promptly: Signed URLs expire in 1 hour
  5. Include CSS inline: For HTML to PDF, include all styles in the HTML
  1. 使用模板处理可复用文档:在控制台中创建发票、报告等模板
  2. 使用HTML端点处理一次性文档:当你不需要可复用模板时
  3. 使用异步端点进行批量处理:异步端点更适合生成大量PDF
  4. 及时下载:临时URL1小时后过期
  5. 内联CSS样式:HTML转PDF时,需将所有样式包含在HTML中