Use case
适合把账单系统、后台管理或自动化流程中的发票 JSON 转成 PDF。网页工具用于人工处理,API 用于稳定的服务端自动化。
PDF Tools API
在后端、批处理或产品流程中生成发票 PDF,不必自己维护 PDF 处理基础设施;成功请求按 Credits 计费。
Credits
1 Credit / call
1 Credit per successful API request. Failed processing attempts are refunded automatically.
Pricing
1,000 Credits = $1
Every signed-in user receives 100 free API Credits each month.
Endpoint
/api/external/invoice-generator/pdfUse your API Key in the x-api-key header.
适合把账单系统、后台管理或自动化流程中的发票 JSON 转成 PDF。网页工具用于人工处理,API 用于稳定的服务端自动化。
curl -X POST https://itextmaster.com/api/external/invoice-generator/pdf \
-H 'x-api-key: YOUR_API_KEY' \
-F 'invoiceNumber=INV-001' \
-F 'fromName=Your Company' \
-F 'billToName=Client Name' \
-F 'items=[{"description":"Consulting","quantity":10,"rate":150}]' \
--output invoice.pdfcurl -X POST https://itextmaster.com/api/external/invoice-generator/pdf \
-H 'x-api-key: YOUR_API_KEY' \
-F 'invoiceNumber=INV-001' \
-F 'fromName=Your Company' \
-F 'billToName=Client Name' \
-F 'items=[{"description":"Consulting","quantity":10,"rate":150}]' \
--output invoice.pdfcurl -X POST https://itextmaster.com/api/external/invoice-generator/pdf \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY' \
-d '{
"invoiceNumber": "INV-001",
"from": { "name": "Your Company", "email": "you@example.com" },
"billTo": { "name": "Client Name", "email": "client@example.com" },
"items": [{ "description": "Consulting", "quantity": 10, "rate": 150 }]
}' \
--output invoice.pdfimport { writeFile } from 'node:fs/promises';
const response = await fetch('https://itextmaster.com/api/external/invoice-generator/pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.ITEXTMASTER_API_KEY
},
body: JSON.stringify({
invoiceNumber: 'INV-001',
from: { name: 'Your Company', email: 'you@example.com' },
billTo: { name: 'Client Name', email: 'client@example.com' },
items: [{ description: 'Consulting', quantity: 10, rate: 150 }]
})
});
if (!response.ok) {
throw new Error(await response.text());
}
await writeFile('invoice.pdf', Buffer.from(await response.arrayBuffer()));import os
import requests
response = requests.post(
'https://itextmaster.com/api/external/invoice-generator/pdf',
headers={
'Content-Type': 'application/json',
'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
},
json={
'invoiceNumber': 'INV-001',
'from': {'name': 'Your Company', 'email': 'you@example.com'},
'billTo': {'name': 'Client Name', 'email': 'client@example.com'},
'items': [{'description': 'Consulting', 'quantity': 10, 'rate': 150}],
},
)
response.raise_for_status()
with open('invoice.pdf', 'wb') as f:
f.write(response.content)invalid_invoice_payload发票 JSON 格式错误或缺少必填字段。
invalid_api_keyx-api-key 缺失、无效或已经轮换。
insufficient_credits账号 API Credits 不足。
invoice_pdf_generation_failed发票 PDF 渲染失败;失败处理会自动退回 Credits。
invoice.pdf,响应头会返回本次消耗的 Credits 和剩余额度。
Content-TypeContent-DispositionX-Credits-ChargedX-Credit-Balance成功的 发票生成 API 请求会消耗 API Credits;失败处理会自动退回。每个登录用户每月有 100 个免费 API Credits,1,000 Credits = $1。
浏览器本地处理的网站工具不消耗 API Credits;只有通过 API Key 发起的自动化请求才按 Credits 计费。
不建议。API Key 应保存在服务端、队列任务或自动化脚本中。
Create an API Key, test 发票生成 API, and buy more Credits only when automation volume grows.