跳转到主要内容

PDF Tools API

Rotate PDF API

Fix page orientation in automated document intake, scanning, and review workflows with a simple PDF rotation endpoint.

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/rotate-pdf

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

cURL example

curl -X POST https://itextmaster.com/api/external/pdf-tools/rotate-pdf \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "files": [
      { "name": "input.pdf", "dataBase64": "JVBERi0xLjcK..." }
    ],
    "options": {"angle":90,"pages":[1,3,5]}
  }' \
  --output rotated.pdf

Node.js example

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

const response = await fetch('https://itextmaster.com/api/external/pdf-tools/rotate-pdf', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.ITEXTMASTER_API_KEY
  },
  body: JSON.stringify({
  files: [
    { name: 'input.pdf', dataBase64: 'JVBERi0xLjcK...' }
  ],
  options: {"angle":90,"pages":[1,3,5]}
})
});

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

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

Python example

import os
import requests

response = requests.post(
    'https://itextmaster.com/api/external/pdf-tools/rotate-pdf',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
    },
    json={
        'files': [
            {'name': 'input.pdf', 'dataBase64': 'JVBERi0xLjcK...'}
        ],
        'options': {'angle':90,'pages':[1,3,5]}
    },
)
response.raise_for_status()

with open('rotated.pdf', 'wb') as f:
    f.write(response.content)

Error codes

401invalid_api_key

The x-api-key header is missing, invalid, or has been rotated.

402insufficient_credits

The account does not have enough API Credits for the request.

422pdf_tool_processing_failed

The file, options, or PDF structure could not be processed.

Limits

  • Angles should use supported right-angle rotations such as 90, 180, or 270 degrees.
  • Page numbers must exist in the input PDF.
  • Encrypted PDFs may need to be unlocked first.

Example output

rotated.pdf with X-Credits-Charged: 1 and X-Credit-Balance response headers.

X-Credits-Charged: 1

X-Credit-Balance: 99

Content-Disposition: attachment; filename="rotated.pdf"

FAQ

Can I rotate only selected pages?

Yes. Pass a pages array to rotate only specific pages, or use all pages when your workflow requires it.

Does rotation change file quality?

Rotation updates page orientation without rasterizing normal PDF content.

How are Credits charged?

Each successful Rotate PDF API request uses 1 Credit.

Start with 100 free API Credits

Create an API Key, test Rotate PDF API, and buy more Credits only when automation volume grows.