Invoice 生成器 API
程序化 PDF Invoice 生成
通过我们的 RESTful API 程序化生成专业 PDF Invoice。非常适合将 Invoice 生成集成到您的应用程序中。
菜单
API 端点
POST
https://yourdomain.com/api/generate-pdf
生成并下载 PDF Invoice
功能特性
高质量 PDF 生成
使用 Puppeteer 生成像素级完美格式的专业 PDF Invoice
多语言支持
支持英语、中文(简体和繁体)、日语、韩语和西班牙语
多种 PDF 格式
支持 A4 和 Letter 页面格式,可自定义页边距
输入验证
全面验证 Invoice 数据以确保数据完整性
安全和速率限制
内置速率限制和输入清理以确保安全
高可靠性
强大的错误处理和自动资源清理
使用示例
以下是如何使用 API 生成 PDF Invoice:
JavaScript
// Using fetch API
const response = await fetch('https://yourdomain.com/api/generate-pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
invoice: {
invoiceNumber: 'INV-001',
date: '2024-07-20',
dueDate: '2024-08-20',
currency: 'USD',
from: {
name: 'Your Company',
email: '[email protected]',
address1: '123 Business St',
city: 'Business City',
state: 'BC',
postalCode: '12345',
country: 'Country'
},
to: {
name: 'Client Name',
email: '[email protected]',
address1: '456 Client Ave',
city: 'Client City',
state: 'CC',
postalCode: '67890',
country: 'Country'
},
items: [{
id: '1',
description: 'Service Description',
quantity: 1,
rate: 100,
amount: 100
}],
subtotal: 100,
taxRate: 10,
tax: 10,
total: 110,
notes: 'Thank you for your business!',
terms: 'Payment due in 30 days'
},
options: {
locale: 'en',
pdfOptions: {
format: 'A4'
}
}
})
});
if (response.ok) {
const blob = await response.blob();
// Download the PDF
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'invoice.pdf';
a.click();
}
速率限制
为确保公平使用和系统稳定性,适用以下速率限制:
超出速率限制
如果您超出速率限制,将收到 429 状态码。请等待后再发起其他请求。
10
每个 IP 地址每 15 分钟 10 个请求
100KB
最大请求大小:100KB
30s
请求超时:30 秒
常见问题
Test API
Try the API with a sample request: