Use case
サーバー側でレポート、領収書、明細、社内画面をPDF化する場面で使います。手作業の確認はWebツール、安定したサーバー側処理はAPIに分ける設計です。
PDF Tools API
バックエンド、バッチ処理、プロダクト内のワークフローにHTMLをPDFに変換を組み込み、PDF処理基盤の自前運用を減らします。
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/html-to-pdf/pdfUse your API Key in the x-api-key header.
サーバー側でレポート、領収書、明細、社内画面をPDF化する場面で使います。手作業の確認はWebツール、安定したサーバー側処理はAPIに分ける設計です。
curl -X POST https://itextmaster.com/api/external/html-to-pdf/pdf \
-H 'x-api-key: YOUR_API_KEY' \
-F 'html=@index.html;type=text/html' \
-F 'pageSize=A4' \
-F 'printBackground=true' \
--output html-to-pdf.pdfcurl -X POST https://itextmaster.com/api/external/html-to-pdf/pdf \
-H 'x-api-key: YOUR_API_KEY' \
-F 'html=@index.html;type=text/html' \
-F 'pageSize=A4' \
-F 'printBackground=true' \
--output html-to-pdf.pdfcurl -X POST https://itextmaster.com/api/external/html-to-pdf/pdf \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY' \
-d '{
"html": "<!doctype html><html><body><h1>Report</h1></body></html>",
"pageSize": "A4",
"printBackground": true
}' \
--output html-to-pdf.pdfimport { writeFile } from 'node:fs/promises';
const response = await fetch('https://itextmaster.com/api/external/html-to-pdf/pdf', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.ITEXTMASTER_API_KEY
},
body: JSON.stringify({
html: '<!doctype html><html><body><h1>Report</h1></body></html>',
pageSize: 'A4',
printBackground: true
})
});
if (!response.ok) {
throw new Error(await response.text());
}
await writeFile('html-to-pdf.pdf', Buffer.from(await response.arrayBuffer()));import os
import requests
response = requests.post(
'https://itextmaster.com/api/external/html-to-pdf/pdf',
headers={
'Content-Type': 'application/json',
'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
},
json={
'html': '<!doctype html><html><body><h1>Report</h1></body></html>',
'pageSize': 'A4',
'printBackground': True,
},
)
response.raise_for_status()
with open('html-to-pdf.pdf', 'wb') as f:
f.write(response.content)invalid_payloadJSONまたはmultipartに必要なHTML、URL、ファイル入力がありません。
invalid_api_keyx-api-keyがない、無効、またはローテーション済みです。
insufficient_creditsアカウントのAPI Creditsが不足しています。
conversion_failedサーバー側レンダリングで変換を完了できませんでした。失敗分のCreditsは自動で戻ります。
html-to-pdf.pdf とともに、使用Creditsと残高を示すレスポンスヘッダーが返ります。
Content-TypeContent-DispositionX-Credits-ChargedX-Credit-Balance成功したHTML PDF 変換 APIリクエストはAPI Creditsを使います。処理に失敗した分は自動で返却されます。ログイン済みユーザーには毎月100 free API Creditsがあり、1,000 Credits = $1です。
ブラウザ内で処理するWebツールはAPI Creditsを使いません。API Keyを使う自動化リクエストだけが対象です。
推奨しません。API Keyはバックエンド、キュー、サーバー側ジョブに置いてください。
Create an API Key, test HTML PDF 変換 API, and buy more Credits only when automation volume grows.