THotPDF.ValidatePDFA4 Method
Enterprise edition: this feature ships with HotPDF Enterprise. Add HPDFEnterprise to a uses clause (C++Builder: #pragma link "HPDFEnterprise"); other editions keep 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 selects metadata inference or an explicit conformance profile, while THPDFPDFA4IssueSeverity distinguishes advisory diagnostics from validation errors
Options
| Field | Purpose |
|---|---|
Profile | Selects automatic metadata-based detection, base, engineering, or associated-file validation |
MaxObjects | Bounds iterative object-graph traversal and defaults to 1,000,000 objects |
MaxIssues | Bounds retained diagnostics and defaults to 1,024 issues |
MaxDecodedBytes | Bounds cumulative decoded metadata, ICC, and content-stream bytes and defaults to 64 MiB |
MaxContentTokens | Bounds cumulative content-stream tokens and defaults to 4,000,000 tokens |
CheckEmbeddedFonts | Checks rendering fonts for an embedded font program |
CheckAnnotationAppearances | Checks annotation flags and normal appearance streams |
CheckOptionalContent | Checks optional-content configuration names and uniqueness |
CheckColourSpaces | Checks painted device color, ICC profiles, output intents, defaults, images, shadings, forms, and transparency groups |
CheckTransparency | Checks painted alpha, soft masks, blend modes, and page-level blending-space coverage |
CheckCompositeFonts | Checks Type 0 descendants, CIDSystemInfo, CMap compatibility, and CIDToGIDMap constraints |
CheckMetadataPackets | Checks 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 color, 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
Color and transparency findings are based on paint operators rather than color-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 colors 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 while 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 behavior
EndDoc automatically runs the validator for '4', '4E', and '4F' and raises before serialization 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, while 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, Catalog AF array, and name tree are emitted together