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 caller-supplied sRGB ICC profile

Each output page contains a losslessly compressed RGB raster image at the requested DPI, with the 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

OptionDefaultMeaning
DPI150Requested physical resolution, accepted range 36 to 1200
MaxPages1000Maximum number of loaded source pages
MaxPixelsPerPage40,000,000Maximum page pixels and maximum individual source-image pixels
MaxTotalPixels500,000,000Maximum accumulated output raster pixels
MaxRasterBytes256 MiBMaximum page or source-image raster allocation, checked conservatively at four bytes per pixel
MaxOutputBytes256 MiBMaximum staged PDF size, enforced before stream allocation and writes
MaxDecodedStreamBytes64 MiBBounds each filter chain, each page's combined content preflight, individual native stream-read callbacks, individual encoded source-image streams and the native output validator
MaxTotalDecodedBytes256 MiBBounds additional native filtered-decoder work across the conversion, combined content preflight across pages, and accumulated native stream-read callbacks across pages
MaxInputObjects200,000Maximum already-loaded indirect object count
CancellationTokennilBorrowed token checked before work, during native rendering and decoding, and before publication
CheckpointnilBorrowed synchronous callback invoked with a nil sender at conversion and native resource checkpoints; do not re-enter 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, whilst 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 whilst it temporarily applies these settings

Rendering and colour

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 recognised 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 colour-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

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