THotPDF.ValidatePDFA4 Method

Enterprise edition: this feature ships with HotPDF Enterprise. Add HPDFEnterprise to a uses clause (C++Builder: #pragma link "HPDFEnterprise"); other editions retain the declaration and raise EHPDFEnterpriseRequired

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 picks metadata inference or an explicit conformance profile, whilst THPDFPDFA4IssueSeverity distinguishes advisory diagnostics from validation errors

Options

FieldPurpose
ProfilePicks 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; local /DefaultGray, /DefaultRGB and /DefaultCMYK resources and transparency-group /Group /CS dictionaries cover only the stream or group in which they are in scope without masking uncalibrated device colours or transparency on the parent page or in child Form XObjects that declare their own /Resources, and pushbutton widgets (/FT /Btn with /Ff bit 17 $10000, direct or inherited from /Parent) accept a single appearance stream under /AP /N whilst checkboxes and radio buttons continue to require a state dictionary

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 behaviour

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

The validator body is HPDFPreflightValidatePDFA4 in the core unit HPDFPDFA4Validation, which ships with every edition so the EndDoc check runs everywhere, whilst the explicit ValidatePDFA4 entry points above remain Enterprise-gated

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, catalogue AF array and name tree are emitted together

Related APIs