Manipulation and Conversion

The PDF Toolkit covers the most common document manipulation workflows with a JSON-first API.

Core endpoints

Endpoint Purpose
POST /v1/pdf/merge Merge 2-20 PDFs into one
POST /v1/pdf/split Split a PDF into parts or pages
POST /v1/pdf/rotate Rotate selected pages
POST /v1/pdf/compress Reduce file size
POST /v1/pdf/watermark Add a text watermark
POST /v1/pdf/protect Encrypt or decrypt a PDF
POST /v1/pdf/to-images Render PDF pages as PNG or JPEG

Python SDK examples

Merge PDFs

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.merge(
        pdf_urls=[
            "https://toolkitapi.io/a.pdf",
            "https://toolkitapi.io/b.pdf",
        ]
    )
    print(result["page_count"])

Split pages

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.split(
        url="https://toolkitapi.io/report.pdf",
        pages="1-3,4-6",
    )
    print(result["total_parts"])

Rotate pages

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.rotate(
        90,
        url="https://toolkitapi.io/report.pdf",
        pages="1-2",
    )
    print(result["rotated_pages"])

Compress a PDF

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.compress(url="https://toolkitapi.io/report.pdf")
    print(result["savings_percent"])

Add a watermark

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.watermark(
        "CONFIDENTIAL",
        url="https://toolkitapi.io/report.pdf",
        opacity=0.12,
        angle=45,
    )
    print(result["watermarked_pages"])

Protect a document

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.protect(
        url="https://toolkitapi.io/report.pdf",
        action="encrypt",
        user_password="open123",
        owner_password="owner456",
    )
    print(result["is_encrypted"])

Convert pages to images

from toolkitapi import PDF

with PDF(api_key="tk_...") as pdf:
    result = pdf.to_images(
        url="https://toolkitapi.io/report.pdf",
        pages="1-2",
        format="jpeg",
        dpi=200,
    )
    print(result["rendered_pages"])

Tips

  • Most endpoints accept either pdf as base64 or url as a public PDF URL
  • Use to_images before OCR only when you need visual page output for another workflow
  • Use protect when you need either password creation or password removal in one route