THotPDF.ValidatePDFA4 Method

Validates a generated or loaded object graph against the supported PDF/A-4 base, PDF/A-4e engineering, or PDF/A-4f associated-file profile and returns stable structured diagnostics

Declaration

function ValidatePDFA4(
  const Options: THPDFPDFA4ValidationOptions;
  out Issues: THPDFPDFA4ValidationIssues): boolean; overload;

function ValidatePDFA4(
  const Options: THPDFPDFA4ValidationOptions;
  out Findings: THPDFComplianceFindings): boolean; overload;

Unit

HPDFDoc

Profile and severity types

THPDFPDFA4Profile = (
  p4pAutomatic,
  p4pBase,
  p4pEngineering,
  p4pAssociatedFiles
);

THPDFPDFA4IssueSeverity = (
  p4isWarning,
  p4isError
);

THPDFPDFA4Profile selects metadata inference or an explicit conformance profile, while THPDFPDFA4IssueSeverity distinguishes advisory diagnostics from validation errors

Options

FieldPurpose
ProfileSelects automatic metadata-based detection, base, engineering, or associated-file validation
MaxObjectsBounds iterative object-graph traversal and defaults to 1,000,000 objects
MaxIssuesBounds retained diagnostics and defaults to 1,024 issues
MaxDecodedBytesBounds cumulative decoded metadata, ICC, and content-stream bytes and defaults to 64 MiB
MaxContentTokensBounds cumulative content-stream tokens and defaults to 4,000,000 tokens
CheckEmbeddedFontsChecks rendering fonts for an embedded font program
CheckAnnotationAppearancesChecks annotation flags and normal appearance streams
CheckOptionalContentChecks optional-content configuration names and uniqueness
CheckColourSpacesChecks painted device colour, ICC profiles, output intents, defaults, images, shadings, forms, and transparency groups
CheckTransparencyChecks painted alpha, soft masks, blend modes, and page-level blending-space coverage
CheckCompositeFontsChecks Type 0 descendants, CIDSystemInfo, CMap compatibility, and CIDToGIDMap constraints
CheckMetadataPacketsChecks every metadata stream for UTF-8, packet-header, RDF envelope, and PDF/A identification constraints

Diagnostics

Each THPDFPDFA4ValidationIssue reports severity, a stable namespaced code, the applicable ISO 19005-4 clause, object path, object number, zero-based page index when known, and a human-readable message

The THPDFComplianceFindings overload exposes the same traversal through the shared machine-readable finding model with a PDF/A-4 profile and crsNotAttempted repair state

The validator covers PDF 2.0 identification, trailer ID and encryption state, every metadata packet, Info restrictions, ICC headers and channel counts, document and page output intents, painted device colour, inherited graphics state across content-stream arrays and nested Form XObjects, image masks, shadings, transparency, rendered font embedding, composite-font relationships, annotations and appearances, AcroForm restrictions, actions and additional actions, associated files, optional content, external references, and profile-specific 3D or attachment rules

Colour and transparency findings are based on paint operators rather than colour-setting operators alone; content tokenization and decoded-stream reuse are cached while each invocation still evaluates inherited graphics state for its own page or Form context

Decoded-byte, content-token, object, and retained-issue limits fail closed with stable pdfa4.validation.* findings before unbounded work can continue

Example

var
  Options: THPDFPDFA4ValidationOptions;
  Issues: THPDFPDFA4ValidationIssues;
begin
  Options := THPDFPDFA4ValidationOptions.Default;
  Options.Profile := p4pAutomatic;
  if not PDF.ValidatePDFA4(Options, Issues) then
    raise Exception.CreateFmt('%s at %s',
      [String(Issues[0].Code), String(Issues[0].Path)]);
end;

Generation behavior

EndDoc automatically runs the validator for '4', '4E', and '4F' and raises before serialization when an error remains

PDF/A-4 generation omits the trailer Info entry, PDF/A-4f always creates the required EmbeddedFiles name tree, and file-attachment annotations are accepted only by PDF/A-4f where the embedded stream, Filespec, AF relationship, Catalog AF array, and name tree are emitted together

Related APIs