THotPDF.RepairPDFA4 Method
Runs a bounded object-graph transaction that applies deterministic PDF/A-4 normalisation, validates the result, and either commits the complete safe repair set or restores the original document state
Declaration
function RepairPDFA4(
const Options: THPDFPDFA4RepairOptions;
out Report: THPDFPDFA4RepairReport;
out Issues: THPDFPDFA4ValidationIssues): boolean; overload;
function RepairPDFA4(
const Options: THPDFPDFA4RepairOptions;
out Report: THPDFPDFA4RepairReport;
out Issues: THPDFPDFA4ValidationIssues;
out Findings: THPDFComplianceFindings): boolean; overload;
Commit contract
Truemeans the transaction was accepted, including the no-change case for an already compliant documentFalsemeans the transaction rolled back after a limit failure, validation regression, exception, or unmetRequireFullConformancepolicyReport.ValidationSucceededis the authoritative full-conformance result after a committed repair- With default options, safe repairs can commit while unrelated unsafe validation findings remain explicit in
IssuesandFindings
Safe repair boundary
The method can normalise the PDF 2.0 header, create a missing trailer ID, create or repair metadata streams and dictionaries, canonicalise PDF/A identification by namespace URI while preserving any legal RDF prefix, remove forbidden Catalog entries, and remove alternate-presentation structures
UTF-8 XMP repair removes forbidden packet-header byte and encoding attributes, uses the canonical PDF/A identification namespace, writes part=4 and rev=2020, and selects the correct base, engineering, or associated-file conformance property
The repair pipeline never rewrites page or annotation content streams, fonts, colour spaces, transparency, images, graphics operators, or extracted text
Rollback and auditability
Graph snapshots cover dictionary mutations and metadata stream bytes, so rollback restores the original header, trailer state, object graph, XMP payload, and page content
The shared finding overload attaches repair actions, applied, unresolved, failed, or rolled-back status, repair counts, stable rule identifiers, clauses, object paths, object numbers, and page locations
Object, mutation, retained-issue, decoded-byte, and content-token budgets prevent adversarial files from turning repair or its validation gates into unbounded work
Example
var
Options: THPDFPDFA4RepairOptions;
Report: THPDFPDFA4RepairReport;
Issues: THPDFPDFA4ValidationIssues;
begin
Options := THPDFPDFA4RepairOptions.Default;
Options.Profile := p4pAutomatic;
if not PDF.RepairPDFA4(Options, Report, Issues) then
raise Exception.Create('PDF/A-4 repair rolled back');
if not Report.ValidationSucceeded then
LogRemainingPDFA4Issues(Issues);
end;