الانتقال إلى المحتوى الرئيسي

PDF Tools API

رأس وتذييل PDF API

أضف إضافة رأس وتذييل إلى الخلفية أو المعالجة الدورية أو منتجك بدون بناء خدمة 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/pdf-tools/header-footer

Use your API Key in the x-api-key header.

Use case

مناسب لـ إضافة تواريخ وأسماء تقارير ومراجع إلى المستندات المتكررة. استخدم أداة الويب للمراجعة اليدوية، واستخدم API للأتمتة المتكررة على الخادم.

cURL example

curl -X POST https://itextmaster.com/api/external/pdf-tools/header-footer \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"headerText":"Quarterly Report","footerText":"Page {page} of {total}"}' \
  --output header-footer.pdf

Multipart example

curl -X POST https://itextmaster.com/api/external/pdf-tools/header-footer \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"headerText":"Quarterly Report","footerText":"Page {page} of {total}"}' \
  --output header-footer.pdf

JSON base64 example

curl -X POST https://itextmaster.com/api/external/pdf-tools/header-footer \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "file": { "name": "input.pdf", "dataBase64": "JVBERi0xLjcK..." },
    "options": {"headerText":"Quarterly Report","footerText":"Page {page} of {total}"}
  }' \
  --output header-footer.pdf

Node.js example

import { writeFile } from 'node:fs/promises';

const response = await fetch('https://itextmaster.com/api/external/pdf-tools/header-footer', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.ITEXTMASTER_API_KEY
  },
  body: JSON.stringify({
  file: { name: 'input.pdf', dataBase64: 'JVBERi0xLjcK...' },
  options: {"headerText":"Quarterly Report","footerText":"Page {page} of {total}"}
})
});

if (!response.ok) {
  throw new Error(await response.text());
}

await writeFile('header-footer.pdf', Buffer.from(await response.arrayBuffer()));

Python example

import os
import requests

response = requests.post(
    'https://itextmaster.com/api/external/pdf-tools/header-footer',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
    },
    json={
        'file': {'name': 'input.pdf', 'dataBase64': 'JVBERi0xLjcK...'},
        'options': {'headerText': 'Quarterly Report', 'footerText': 'Page {page} of {total}'}
    },
)
response.raise_for_status()

with open('header-footer.pdf', 'wb') as f:
    f.write(response.content)

Error codes

401invalid_api_key

ترويسة x-api-key غير موجودة أو غير صالحة أو تم تدويرها.

402insufficient_credits

الحساب لا يحتوي على API Credits كافية.

422pdf_tool_processing_failed

تعذرت معالجة الملف أو الخيارات أو بنية PDF. يتم رد Credits تلقائيًا عند الفشل.

Limits

  • يتطلب ملف PDF صالحًا أو بيانات إدخال صحيحة.
  • استدع API من الخادم حتى لا يظهر API Key في المتصفح.
  • اختبر ملفات ممثلة قبل تشغيل دفعات كبيرة.

Response headers

header-footer.pdf مع ترويسات توضّح Credits المستخدمة والرصيد المتبقي.

Content-Type
نوع MIME للملف الناتج، غالبًا application/pdf أو application/zip.
Content-Disposition
اسم تنزيل الملف الناتج.
X-Credits-Charged
Credits التي تم احتسابها للطلب الناجح.
X-Credit-Balance
رصيد API Credits بعد الطلب.

FAQ

كم تكلفة رأس وتذييل PDF API؟

الطلبات الناجحة تستخدم API Credits؛ وتتم إعادة Credits تلقائيًا عند فشل المعالجة. يحصل كل مستخدم مسجل على 100 free API Credits شهريًا، و1,000 Credits = $1.

هل تستخدم أدوات الويب API Credits؟

لا. الأدوات التي تعمل داخل المتصفح لا تستهلك API Credits. تتم المحاسبة فقط على الطلبات التي تستخدم API Key.

هل يمكن استدعاء API من المتصفح؟

لا يُنصح بذلك. احتفظ بـ API Key في الخادم أو قائمة الانتظار أو مهام الأتمتة الخلفية.

Start with 100 free API Credits

Create an API Key, test رأس وتذييل PDF API, and buy more Credits only when automation volume grows.