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

PDF Tools API

قص PDF API

أضف قص 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/pdf-tools/crop-pdf

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/crop-pdf \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"margin":36}' \
  --output cropped.pdf

Multipart example

curl -X POST https://itextmaster.com/api/external/pdf-tools/crop-pdf \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"margin":36}' \
  --output cropped.pdf

JSON base64 example

curl -X POST https://itextmaster.com/api/external/pdf-tools/crop-pdf \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "file": { "name": "input.pdf", "dataBase64": "JVBERi0xLjcK..." },
    "options": {"margin":36}
  }' \
  --output cropped.pdf

Node.js example

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

const response = await fetch('https://itextmaster.com/api/external/pdf-tools/crop-pdf', {
  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: {"margin":36}
})
});

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

await writeFile('cropped.pdf', Buffer.from(await response.arrayBuffer()));

Python example

import os
import requests

response = requests.post(
    'https://itextmaster.com/api/external/pdf-tools/crop-pdf',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
    },
    json={
        'file': {'name': 'input.pdf', 'dataBase64': 'JVBERi0xLjcK...'},
        'options': {'margin': 36}
    },
)
response.raise_for_status()

with open('cropped.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

cropped.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.