JSON Job Configuration

THPDFJobProcessor accepts a JSON document describing ordered PDF operations and returns a JSON result with per-operation status

Supported operations

merge combines multiple input PDFs into a single output file using AppendPagesFromDocument

split extracts page ranges from an input PDF into separate output files using ExtractLoadedPagesToPDF

optimise recompresses FlateDecode and LZWDecode streams with a minimum savings threshold

encrypt applies AES-256, AES-128, RC4-128, or RC4-40 encryption with caller-specified passwords and key type

validate runs a built-in validation policy and returns the report text

JSON schema

Input must contain one complete JSON value with valid separators, closed containers, valid string escapes, and only JSON whitespace outside strings; trailing content and numbers outside the finite Double range are rejected

The parser accepts at most 64 nested value levels, counting the root value as the first level; malformed or excessively nested jobs fail before any operation runs, and partially parsed values are released

The input is an object with an operations array; each operation has a type field and type-specific parameters

The output is an object with a results array; each result carries type, status (ok, error, or skipped), and operation-specific fields

String values preserve escaped Unicode characters, including \u0000; finite numbers use a locale-independent decimal point and can be serialized outside the signed 64-bit range

Numeric values are stored as Double and follow the compiler runtime's floating-point conversion precision, so integers beyond its exact integer range can be rounded on input; GetInt and GetInt64 return the supplied default when the rounded value is outside their signed integer range

Per-operation budgets

Every operation can contain a budget object with memoryBytes, timeMilliseconds, objectCount, decompressionRatio, and outputBytes limits

{"operations":[{"type":"optimise","input":"in.pdf","output":"out.pdf",
  "budget":{"memoryBytes":268435456,"timeMilliseconds":30000,
  "objectCount":1000000,"decompressionRatio":200,"outputBytes":1073741824}}]}

A limit violation returns status=budget-exceeded plus metric, observed, limit, and elapsedMilliseconds without aborting later operations

Memory budgets are also applied to per-stream and document decode accounting so expansion is bounded before large buffers are retained

Opaque handle API

HPDFDocCreate returns an opaque THPDFDocHandle wrapping a THotPDF instance; HPDFDocLoadFromFile, HPDFDocGetPageCount, HPDFDocSaveLoadedDocument, and HPDFDocRunJob operate on the handle; HPDFDocDestroy releases it

These source-compatible Pascal helpers remain available to Delphi and C++Builder callers

HotPDF Stable C Callback ABI provides the flat versioned C boundary for random-access input, streaming output, cancellation, progress, diagnostics, and opaque handle lifecycle