Use case
مناسب لـ تصيير التقارير والإيصالات والكشوف والواجهات الداخلية على الخادم. استخدم أداة الويب للمراجعة اليدوية، واستخدم 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.
مناسب لـ تصيير التقارير والإيصالات والكشوف والواجهات الداخلية على الخادم. استخدم أداة الويب للمراجعة اليدوية، واستخدم 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_payloadطلب JSON أو multipart يفتقد إدخال HTML أو URL أو الملف المطلوب.
invalid_api_keyترويسة x-api-key غير موجودة أو غير صالحة أو تم تدويرها.
insufficient_creditsالحساب لا يحتوي على API Credits كافية.
conversion_failedلم تكتمل عملية التصيير على الخادم. يتم رد Credits تلقائيًا عند الفشل.
html-to-pdf.pdf مع ترويسات توضّح Credits المستخدمة والرصيد المتبقي.
Content-TypeContent-DispositionX-Credits-ChargedX-Credit-Balanceالطلبات الناجحة تستخدم API Credits؛ وتتم إعادة Credits تلقائيًا عند فشل المعالجة. يحصل كل مستخدم مسجل على 100 free API Credits شهريًا، و1,000 Credits = $1.
لا. الأدوات التي تعمل داخل المتصفح لا تستهلك API Credits. تتم المحاسبة فقط على الطلبات التي تستخدم API Key.
لا يُنصح بذلك. احتفظ بـ API Key في الخادم أو قائمة الانتظار أو مهام الأتمتة الخلفية.
Create an API Key, test تحويل HTML إلى PDF API, and buy more Credits only when automation volume grows.