Available in the Single, SmallBusiness and Enterprise editions
RunPdfNativeWorker executes one request in a fresh, separately built worker executable without loading PDFium into the calling process
Windows requires Windows 10 with less privileged AppContainer (LPAC) support or newer and the corresponding operating-system APIs and policy rights; Free Pascal on Linux has a separate namespace/seccomp backend described below, whilst other targets return nwsUnavailable
function RunPdfNativeWorker(const Input, Parameters: TBytes; Operation: Cardinal; const Options: TPdfNativeWorkerOptions; const Token: IPdfCancellationToken; out Output: TBytes; out Envelope: TPdfNativeWorkerEnvelope; out Report: TPdfNativeWorkerReport): Boolean;
Start with TPdfNativeWorkerOptions.Default, set WorkerFileName to the trusted executable, and add its native DLLs to RuntimeFiles; keep the input and parameter arrays immutable until the synchronous call returns
The caller may run this synchronous operation on an application worker thread; cancellation is observed by the parent and terminates the Windows job or verified Linux process group even when the native function never polls a token
On Free Pascal for Windows, caller-supplied path strings follow their string code page, consistent with TFileStream. System-provided profile and temporary paths stay in UTF-16 through cleanup
| Option | Default and boundary |
|---|---|
| DeadlineMs | 30000 ms, nonzero and at most one day, measured with the monotonic async clock |
| MemoryLimitBytes | 512 MiB, at least 16 MiB and representable as a native pointer-sized value, Windows process/job committed-memory limits; Linux RLIMIT_AS virtual address-space limit, not committed memory |
| CpuTimeLimitSeconds | At most 86400 seconds; zero preserves the Windows default without an explicit CPU cap and derives the Linux hard CPU limit by rounding DeadlineMs up to whole seconds; Windows job CPU-limit enforcement can overshoot because the operating system samples usage periodically |
| SandboxLauncherFileName | Linux trusted launcher path; defaults to pdfium-worker-sandbox beside WorkerFileName; ignored on Windows |
| NamespaceToolFileName | Linux defaults to /usr/bin/bwrap and requires a root-owned regular executable without setuid/setgid or group/other write permission; ignored on Windows |
| MaxInputBytes | 64 MiB, at most 256 MiB |
| MaxOutputBytes | 64 MiB, nonzero and at most 256 MiB, excluding the fixed 64-byte response envelope |
| MaxStagingBytes | 512 MiB, at most 1 GiB, covering the request, input, worker and runtime files |
| MaxProfileStorageBytes | 8 MiB, at most 64 MiB, Windows only, covering initial logical file and registry-value data in the newly created private profile; zero requires empty initial data |
| MaxProfileEntries | 256, nonzero and at most 4096, Windows only, counting profile directories, files, registry keys and values before native code is allowed to run |
| RuntimeFiles | At most 16 trusted files, copied under their base names without overwriting existing staging files |
| TemporaryDirectory | Operating-system temporary directory when empty; each request owns a unique child directory |
| OutputFileName | Optional destination, retained only by the parent and replaced after successful execution, framing checks and cleanup |
DuplicateToken and AccessCheck, lowers integrity to Untrusted, checks no-write-up policy, and permanently removes every privilege except SeChangeNotifyPrivilege before allowing executionMoveFileExW; cancellation and the deadline are checked during staging and immediately before replacementThe deadline is checked around setup, staging, native execution and publication; synchronous operating-system setup, flush, process teardown and profile cleanup can extend total call duration beyond that deadline
The memory limits constrain Windows job/process commit, not all kernel, driver or mapped-image memory; raw peak accounting may include transient failed commit charges and is reported without clipping
The parent inventories the entire newly created profile package directory and its registry storage before changing inheritable permissions; reparse points, hard links, registry symbolic-link values, nesting beyond 16 levels and exceeded logical-data/entry budgets reject before untrusted code executes
Every discovered file, directory and registry key receives a protected DACL with explicit package write/delete/security-change denials, caller/SYSTEM access, package read access and an OWNER RIGHTS entry that suppresses implicit WRITE_DAC
The actual suspended-child token is checked against each resulting descriptor: read rights must pass and every individual write, delete, DACL and owner bit must fail; the profile directory remains pinned against rename until execution has ended
Untrusted integrity and no-write-up policy provide additional restrictions; they do not replace the explicit DACL checks, because AppContainer access semantics can still permit changes to its own profile objects
Custom workers receive PDFIUM_WORKER_PROFILE and PDFIUM_WORKER_PROFILE_NAME as bounded environment metadata; use these paths when Windows profile lookup APIs are unavailable under LPAC, and perform output through the response pipe
Native providers that require a writable cache or temporary files are outside this read-only profile and may reject; the built-in inspection, rendering, extraction and ordinary save operations use memory and the response pipe
Profile byte accounting measures initial logical file/value data, and entry accounting bounds the inventory; it does not measure filesystem allocation or impose a quota on storage written by privileged operating-system brokers
The staging budget bounds files copied by the parent, the profile policy denies direct worker profile growth, and the response budget bounds accepted pipe data; these are separate from a system-wide disk quota
Network capabilities are absent and LPAC restrictions are required; exact native network failure codes depend on the Windows provider and policy configuration, so deploy with the operating system's isolation enforcement intact
The qualified deployment uses Free Pascal on physical Linux x86_64 with bubblewrap 0.11.1, unprivileged user namespaces, PID/mount/network/IPC/UTS namespaces, seccomp-BPF, pidfd operations and close_range; the launcher requires Linux kernel 5.9 or newer plus the relevant host policy permissions, and rejects missing restrictions instead of running without containment
Build the trusted launcher with cc -std=c11 -O2 -Wall -Wextra -Werror tools/PdfWorker/PdfWorkerSandbox.c -o pdfium-worker-sandbox, build PdfWorker.dpr with the library and Lazarus LCL unit search paths, and provide the matching libpdfium.so through RuntimeFiles
The C launcher has little-endian AArch64 build branches, but the executed acceptance profile covers x86_64 only; macOS containment and Delphi Linux deployment have not been qualified
nwsUnavailable when cleanup succeeds. The authorisation write preserves the caller thread's signal mask and pending signalsLinux memory limits bound virtual address space per process, including mappings and thread stacks; they do not provide a cgroup aggregate commit limit or quotas for kernel memory, trusted supervisor overhead or privileged operating-system brokers
Report.Isolation distinguishes the selected backend; Linux reports the actual native SandboxProcessId, address-space/CPU limits and namespace, seccomp, read-only filesystem, no_new_privs and process-group proofs
Linux CPU and resident-memory diagnostics combine periodic native-process samples with reaped supervisor accounting; short workloads can finish between samples, peaks can be missed, and these values are not exact native lifetime totals; CPU-limit classification uses sampled native CPU near the configured hard limit together with the terminating signal
Pre-commit failures preserve the existing destination; if a directory flush fails after rename, nwsPublishFailed returns empty Output with OutputPublished=True because complete bytes have already been atomically replaced
Custom Linux workers must retain the inherited restrictions and use the protocol helpers before processing input; writable caches, arbitrary application paths, network providers and process-based helper tools are outside this profile
Build tools/PdfWorker/PdfWorker.dpr with the library include/unit search paths using Delphi or Free Pascal, matching the native DLL architecture, and deploy the resulting executable as a trusted application asset
For FPC Win64, enable relocations with -WR and use -WB140000000; the worker source enables PE address randomisation and NX flags with SETPEOPTFLAGS, because a fixed, relocation-stripped FPC image can fail to launch in an AppContainer with Windows error 623
On Windows, supply pdfium.dll through RuntimeFiles; it is loaded by absolute path with DLL lookup limited to its private directory and the Windows system directory
Parameters starts with the packed 16-byte TPdfNativePdfParameters record, followed by an optional NUL-free UTF-8 password
| Operation | Result |
|---|---|
| PdfNativeWorkerInspect | UTF-8 JSON containing the page count and PDF file version |
| PdfNativeWorkerRender | Top-down BGRA bytes, Width * Height * 4, each dimension at most 16384 and total bytes within MaxOutputBytes; flags may be zero or FPDF_ANNOT |
| PdfNativeWorkerText | UTF-8 text from the selected zero-based PageIndex without a trailing NUL |
| PdfNativeWorkerSave | Full-save PDF bytes reopened in the worker with the same page count; encrypted or signed documents are explicitly rejected |
The built-in worker does not initialise a form environment, execute document actions, edit signatures, convert dynamic XFA or provide a general TPdf operation dispatcher
ReadPdfNativeWorkerRequest reads the fixed private request/input names; WritePdfNativeWorkerResponse writes one versioned little-endian response envelope and payload to standard output
The parent requires exit code zero, the exact request nonce, operation, protocol version, reserved value and payload length, with no trailing bytes; custom operations should use identifiers outside the built-in range
Framing checks establish request/response identity and bounds, not the semantic safety or standards conformance of arbitrary returned bytes; use the appropriate independent validator when consuming such output
Report retains the terminal status, child PID/exit code, elapsed time, backend-specific job/process peaks or sampled resident-memory diagnostics, CPU accounting, received byte count, at most 64 untrusted response-prefix bytes, containment checks, integrity/no-write-up state, removed-privilege count, initial profile logical bytes/entry count, read-only profile proof, cleanup status and publication result
The byte, privilege and profile diagnostics are named ReceivedBytes, ResponsePrefix, PrivilegesRemoved, ProfileStorageBytes and ProfileStorageEntries; a failed cleanup that prevents publication names the leftover staging path in RetainedDirectory
Status is a TPdfNativeWorkerStatus: nwsSuccess, nwsInvalidOptions, nwsUnavailable, nwsLaunchFailed, nwsDeadline, nwsCancelled, nwsResourceLimit, nwsWorkerFailed, nwsProtocolError, nwsCleanupFailed and nwsPublishFailed; Isolation is a TPdfNativeWorkerIsolation of nwiNone, nwiWindowsLpac or nwiLinuxNamespaces naming the backend actually used
Failure returns an empty Output array; inspect OutputPublished for post-rename durability errors on Linux; a cleanup failure reports the retained directory or profile identity and prevents publication
Native FailFast reporting can remain pending inside Windows; the parent deadline still terminates the worker and prevents publication, so a fail-fast operation may be reported as native failure or deadline expiry depending on operating-system reporting behaviour
Job completion-port limit notifications are used when observed; Windows does not guarantee delivery of every notification, whilst the configured allocation/process limits remain enforced by the operating system
FPdfAsync, API Reference, Microsoft AppContainer and LPAC launch guidance, Microsoft job object semantics