HotPDF Stable C Callback ABI
Enterprise edition: the units behind this feature ship in Lib\Enterprise with HotPDF Enterprise and do not form part of other editions
HotPDFABI.dll exposes flat cdecl functions with fixed-width status values, opaque handles, explicit byte lengths and the versioned hpdf_io_v1 callback structure declared in Lib/hotpdf_abi.h
Build outputs
Run build-HotPDF-ABI.cmd to build Win32 and Win64 DLLs plus import libraries under Lib/ABI/<platform>/Release
The public ABI uses stable lowercase export names, whilst hpdf_abi_version and hpdf_abi_io_v1_size let callers verify the contract before creating a document
Core functions
uint32_t hpdf_abi_version(void);
uint32_t hpdf_abi_io_v1_size(void);
hpdf_status hpdf_document_create(hpdf_document *handle);
hpdf_status hpdf_document_destroy(hpdf_document handle);
hpdf_status hpdf_document_load_from_io(
hpdf_document handle,
const hpdf_io_v1 *io,
const char *password,
size_t password_length);
hpdf_status hpdf_document_page_count(
hpdf_document handle,
uint32_t *page_count);
hpdf_status hpdf_document_save_to_io(
hpdf_document handle,
const hpdf_io_v1 *io);
Versioned I/O structure
hpdf_io_v1 io = {0};
io.struct_size = sizeof(io);
io.abi_version = HPDF_ABI_VERSION_1;
io.user_data = state;
io.read_at = read_at;
io.get_size = get_size;
io.write = write;
io.is_cancelled = is_cancelled;
io.progress = progress;
io.diagnostic = diagnostic;
struct_size is 48 bytes on Win32 and 72 bytes on Win64, flags must be zero for ABI v1, and larger future structures can be distinguished without guessing field layout
All callbacks and exported functions use cdecl, every text pointer has an explicit byte length, and no Delphi string, class, interface, enum, exception or Boolean crosses the boundary
Random-access input
read_at receives an absolute 64-bit offset and writes directly into the parser's destination buffer, whilst get_size reports the immutable source size once when the source is attached
Partial successful reads are accepted and completed through repeated callback calls, so range stores and bounded network readers do not need to allocate an intermediate complete-file buffer
The callback state and source bytes must remain valid until the document handle is destroyed or another source is loaded into the handle
Streamed output
write receives sequential output chunks directly from SaveLoadedDocumentToStream; partial successful writes are retried until the complete chunk is accepted
A zero-byte successful write is rejected as an I/O error because it cannot make forward progress
For JSON execute and two-handle comparison operations, a failed write callback is not called again to publish an error result through the same writer and user-data pair, including when OutputIO and ResultIO share that pair; partial candidate bytes already received by the caller remain the caller's responsibility
Write status values outside the defined non-zero status range, and zero or excessive successful byte counts, become HPDF_STATUS_IO_ERROR; the V1 record layout and successful partial-write behaviour remain unchanged
Status and lifecycle
| Status | Meaning |
|---|---|
HPDF_STATUS_OK | The operation completed |
HPDF_STATUS_INVALID_ARGUMENT | A required pointer or callback is absent or a byte range is invalid |
HPDF_STATUS_INVALID_HANDLE | The handle is null, unknown or already destroyed |
HPDF_STATUS_INCOMPATIBLE_ABI | The structure size, version or flags are unsupported |
HPDF_STATUS_CANCELLED | The cancellation callback requested termination |
HPDF_STATUS_IO_ERROR | An input or output callback failed or violated its count contract |
HPDF_STATUS_PARSE_ERROR | The input was read successfully but was not accepted as a PDF |
HPDF_STATUS_INTERNAL_ERROR | An internal failure was caught before it crossed the ABI |
Each successful hpdf_document_create must be paired with one successful hpdf_document_destroy; repeated destruction returns HPDF_STATUS_INVALID_HANDLE
Opaque handles are monotonic process-local tokens rather than object addresses, so allocator reuse cannot revive a stale handle
Exceptions never cross the C boundary, and the optional diagnostic callback receives the corresponding message bytes before an operation returns an error status
Concurrency
Different handles run concurrently without blocking one another; concurrent operations aimed at the same handle are serialised internally by a per-handle lock, whilst hpdf_document_compare_json_v1 takes both handle locks in a deterministic order so that deadlocks cannot arise
hpdf_document_destroy removes the handle at once, so later lookups return HPDF_STATUS_INVALID_HANDLE, whilst any call already under way finishes on its reference-counted context before the underlying resources are freed
Built-in RFC 3161 HTTP/HTTPS timestamp transport
Callers who would rather not supply their own HTTP client callback can create an explicit built-in timestamp transport with hpdf_network_timestamp_transport_create_v1 (hpdf_network_timestamp_options_v1), assign hpdf_network_timestamp_transport_v1 and the opaque handle to hpdf_signing_operation_v1, and afterwards release the handle with hpdf_network_timestamp_transport_destroy
Alternatively, sign JSON jobs with "timestamp": true can opt in directly without a custom callback extension by specifying "useBuiltinTimestampTransport": true together with an explicit http:// or https:// "timestampURL" (or "timestampServerURL"); by default (false), timestamped signing keeps the fail-closed explicit caller transport behaviour
Legacy Pascal callbacks
THPDFABICallbacks and the HPDFDoc* Pascal helpers remain source compatible for Delphi and C++Builder applications, but native C integrations should use hotpdf_abi.h and the lowercase v1 exports
The callback-backed legacy forms are HPDFDocLoadFromCallbacks, HPDFDocSaveToCallbacks, HPDFDocRunJobWithCallbacks and HPDFDocFreeCallbackBuffer; the first two attach a callback source or sink to an existing handle, the job form returns a caller-owned result buffer, and the free form releases that buffer through the optional Release callback or with FreeMem when none is supplied
THPDFCABIIOV1 is the Pascal declaration of hpdf_io_v1, and THPDFCABISigningOperationV1 extends THPDFCABIOperationV1 with the timestamp transport that signing jobs use
THPDFCABIIOV1 · THPDFCABISigningOperationV1 · JSON job configuration