Loaded PDF to PDF/A-4 Raster Conversion
HPDFArchivalConversion creates a new PDF/A-4 document from the visible page content of a loaded THotPDF document, using strict native rendering and a supplied sRGB ICC profile
Each output page contains a losslessly compressed RGB raster image at the requested DPI, with its original visible dimensions, crop, rotation, and UserUnit reflected in the output page geometry
Use the separate text and vector preserving profile when original embedded fonts, text operators, vector paths, images, OCR layers, and visible annotation or widget appearances must survive; the raster profile does not preserve those structures
Entry points
function HPDFConvertLoadedToPDFA4Raster(Source: THotPDF;
Destination: TStream; const SRGBProfile: TBytes;
const Options: THPDFArchivalConversionOptions;
out Report: THPDFArchivalConversionReport): Boolean;
function HPDFConvertLoadedToPDFA4RasterFile(Source: THotPDF;
const TargetFileName: string; const SRGBProfile: TBytes;
const Options: THPDFArchivalConversionOptions;
out Report: THPDFArchivalConversionReport): Boolean;
Load the source first and keep any caller-owned input stream alive until the source document is destroyed
Use the file entry point for ordinary archival publication: it probes an existing target for source aliasing before creating an exclusive temporary file in the target directory, validates the complete conversion, flushes the file, and replaces the target with MoveFileEx using MOVEFILE_REPLACE_EXISTING and MOVEFILE_WRITE_THROUGH
Conversion, rendering, validation, cancellation, and publication failures retain an existing target file and remove the temporary output
The stream entry point requires an empty, seekable destination at position zero and rejects known aliases of the input through IsLoadedSourceStreamAlias; it publishes bytes only after the complete staged output has passed native validation
A destination write failure triggers a best-effort reset to an empty stream, but an arbitrary device or custom stream may reject that reset and retain a partial write; use the file entry point when file publication must be atomic
Options and resource bounds
| Option | Default | Meaning |
|---|---|---|
DPI | 150 | Requested physical resolution, accepted range 36 through 1200 |
MaxPages | 1000 | Maximum number of loaded source pages |
MaxPixelsPerPage | 40,000,000 | Maximum page pixels and maximum individual source-image pixels |
MaxTotalPixels | 500,000,000 | Maximum accumulated output raster pixels |
MaxRasterBytes | 256 MiB | Maximum page or source-image raster allocation, checked conservatively at four bytes per pixel |
MaxOutputBytes | 256 MiB | Maximum staged PDF size, enforced before stream allocation and writes |
MaxDecodedStreamBytes | 64 MiB | Bounds each filter chain, each page's combined content preflight, individual native stream-read callbacks, individual encoded source-image streams, and the native output validator |
MaxTotalDecodedBytes | 256 MiB | Bounds additional native filtered-decoder work across the conversion, combined content preflight across pages, and accumulated native stream-read callbacks across pages |
MaxInputObjects | 200,000 | Maximum already-loaded indirect object count |
CancellationToken | nil | Borrowed token checked before work, during native rendering and decoding, and before publication |
Checkpoint | nil | Borrowed synchronous callback invoked with a nil sender at conversion and native resource checkpoints; do not reenter the source document |
Decode limits count decoder work and may charge the same filtered stream again during preflight, display-list compilation, and rendering; increasing a budget is an explicit caller decision
Pixel preflight covers both the requested physical resolution and the native renderer's integer DPI after UserUnit scaling; very small units may require additional raster pixels, and fractional page dimensions can introduce subpixel resampling when the image is mapped back onto the physical page
Conversion bounds apply after source loading; configure the loader's own resource limits when accepting untrusted input
The source object graph is retained, while read caches and decode statistics may be populated; rendering settings, cancellation token, backend, and decode-budget settings are restored on success and failure
Give the converter exclusive access to its source document while it temporarily applies these settings
Rendering and color
Every page must render without a native fallback diagnostic, a dropped diagnostic, or a missing-resource failure; unsupported content rejects the conversion instead of publishing an incomplete page
The ICC argument must describe sRGB with a recognized matrix/TRC representation, the standard D50-adapted primaries, and the IEC sRGB transfer function; unrelated RGB profiles, CMYK profiles, malformed profiles, and LUT-based profiles are rejected
The output declares an sRGB OutputIntent and PDF/A-4 XMP metadata; a custom proof or output ICC workflow already configured on the source is rejected because its image-decoder settings cannot be safely reinterpreted as sRGB
The FPC build requires its native codec bridge with LittleCMS available and rejects conversion when that color-management backend is missing
JPEG and JPX image streams, including encoded inline images, have their actual codestream dimensions inspected before native pixel decoding and must agree with the PDF image dictionary
JPEG accepts bounded 8-bit baseline, extended sequential, and progressive headers; JPX accepts bounded J2K SIZ headers and ordinary-length JP2 boxes with at most four components and component precision at most 16 bits
Encoded codecs have an additional conservative working budget of 64 bytes per source pixel, and JPX tile metadata is limited by both MaxInputObjects and 1024 bytes per tile within MaxRasterBytes; the default 256 MiB raster budget therefore permits at most 4,194,304 encoded source pixels, and callers may explicitly increase it for larger images
JBIG2 conversion is rejected because its internal region and symbol allocations cannot be bounded from the available header API; nonterminal image codecs, extended-length JP2 boxes, unsupported wrappers, and wrapped codec streams carrying DecodeParms are also rejected
CCITT fax parameters must retain the declared positive image dimensions; DecodeParms.Columns and Rows overrides that differ from the dictionary, including unknown Rows=0, are rejected before native decoding
These checks bound the known header and allocation profiles accepted by this converter and do not promise a complete process-memory sandbox for every native decoder
Information and quality loss
- Vector content, fonts, transparency, and source color spaces become RGB page pixels; increased DPI improves visual detail but increases memory use and file size
- Output text is not searchable or selectable, and no text layer or OCR output is synthesized
- Annotations, annotation appearances, form fields, widget appearances, and visible signature appearances are omitted rather than baked into the page raster
- Digital signatures, embedded files, scripts, actions, bookmarks, layers as interactive controls, structural tags, and the original document identity are not retained
- The result does not preserve vector editability, original signature validity, PDF/UA accessibility, or source-document semantics
THPDFArchivalConversionReport provides success and cancellation state, source and rendered page counts, raster pixels, output bytes, removed annotation/form/attachment counts, a failure diagnostic, and the native validation findings
FailureKind distinguishes afkNone, afkConversion, afkBudget, and afkCancelled; typed converter budget failures also supply BudgetMetric, BudgetObserved, and BudgetLimit
A checkpoint exception stops the conversion and is reported through the native failure result; wrappers that require the original callback exception category must retain it before the converter catches it
The archive.pdfa4.raster JSON and C ABI operation requires explicit information-loss acceptance, preserves the source handle, delivers the validated PDF and loss report, and applies conservative job-budget caps
Conformance verification
The converter reloads its staged output and requires ValidatePDFA4 with the base PDF/A-4 profile before publication; the native validator covers its documented bounded rule set and is not a proof of every ISO 19005-4 requirement
Independent acceptance can use veraPDF with --flavour 4; the regression fixture containing nonembedded text, transparency, an RGB image, a link, a signature widget, and an attachment passed veraPDF 1.30.2 with no failed rules or checks
Run Tests/Delphi/Run-HotPDFArchivalTests.bat for the focused non-GUI regression suite