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

ocr.layer creates searchable text through the default built-in ASCII engine or explicitly configured local Tesseract/RapidOCR CLI and DLL adapters; see external OCR job configuration

JSON schema

The input must consist of one complete JSON value with valid separators, closed containers and well-formed string escapes, with nothing but JSON whitespace outside strings; trailing content and numbers beyond the finite Double range are refused

The parser tolerates at most 64 nested value levels, with the root value counted as the first level; malformed or over-nested jobs fail before any operation runs, and any 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 keep escaped Unicode characters intact, \u0000 included; finite numbers use a decimal point that does not depend on locale and can be serialised beyond the signed 64-bit range

Numeric values are held as Double and follow the compiler runtime's floating-point conversion precision, so integers outside its exact integer range can be rounded on the way in; GetInt and GetInt64 return the supplied default when the rounded value falls 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 breach 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