PDFiumPas Docs

Concrete document repair providers

Enterprise edition: this unit ships in Lib\Enterprise and is linked by FPdfEnterprise and the PDFiumPasEnt / PDFiumLazEnt packages; see the edition matrix

Add FPdfDocumentRepairProviders and register providers in TPdfDocumentARepairOptions.Providers to execute reviewed changes through the transactional PDF/A repair workflow

Declarations

type
TPdfDocumentColourRepairProvider= class(TInterfacedObject, IPdfDocumentARepairProvider)
  private
    FTargetSpace: TPdfColourSpace;
    FTargetProfile: TBytes;
    FTransform: IPdfColourTransform;
    FOptions: TPdfDocumentColourOptions;
    FLastReport: TPdfDocumentColourReport;
    function GetLastReport: TPdfDocumentColourReport;
  public
    constructor Create(TargetSpace: TPdfColourSpace; const TargetProfile: TBytes;
      Transform: IPdfColourTransform; const Options: TPdfDocumentColourOptions);
    function Supports(Category: TPdfARepairCategory): Boolean;
    function RequiresStableObjectIdentities: Boolean;
    function PreservesObjectIdentities: Boolean;
    function Repair(const Source: TBytes; const Step: TPdfARepairStep;
      const Context: TPdfDocumentARepairContext; out OutputPdf: TBytes;
      out ErrorText: string): Boolean;
    property LastReport: TPdfDocumentColourReport read GetLastReport;
  end;

  TPdfDocumentStructureRepairProvider= class(TInterfacedObject, IPdfDocumentARepairProvider)
  private
    FBaseSourceSha256: string;
    FOperations: TPdfStructureEditOperations;
    FOptions: TPdfStructureEditOptions;
    FLastReport: TPdfStructureEditReport;
    function GetLastReport: TPdfStructureEditReport;
  public
    constructor Create(const BaseSourceSha256: string;
      const Operations: TPdfStructureEditOperations; const Options: TPdfStructureEditOptions);
    function Supports(Category: TPdfARepairCategory): Boolean;
    function RequiresStableObjectIdentities: Boolean;
    function PreservesObjectIdentities: Boolean;
    function Repair(const Source: TBytes; const Step: TPdfARepairStep;
      const Context: TPdfDocumentARepairContext; out OutputPdf: TBytes;
      out ErrorText: string): Boolean;
    property LastReport: TPdfStructureEditReport read GetLastReport;
  end;

  TPdfDocumentTextRepairProvider= class(TInterfacedObject, IPdfDocumentARepairProvider)
  private
    FPlan: TPdfDocumentTextRepairPlan;
    FOptions: TPdfDocumentTextRepairOptions;
    FCategory: TPdfARepairCategory;
    FLastReport: TPdfDocumentTextRepairReport;
  public
    constructor Create(const Plan: TPdfDocumentTextRepairPlan;
      const Options: TPdfDocumentTextRepairOptions; Category: TPdfARepairCategory=parcFonts);
    function Supports(Category: TPdfARepairCategory): Boolean;
    function RequiresStableObjectIdentities: Boolean;
    function PreservesObjectIdentities: Boolean;
    function Repair(const Source: TBytes; const Step: TPdfARepairStep;
      const Context: TPdfDocumentARepairContext; out OutputPdf: TBytes;
      out ErrorText: string): Boolean;
    property LastReport: TPdfDocumentTextRepairReport read FLastReport;
  end;

Color repair

TPdfDocumentColourRepairProvider handles parcColour through ConvertPdfDocumentColours with an explicit target color space, ICC profile and IPdfColourTransform

The provider copies the profile/options, requires complete conversion and forces FailOnUnsupported True plus OutputIntentKind pdoikPdfA, writing the PDF/A GTS_PDFA1 subtype

Source and output budgets are capped by the parent repair limits; cancellation is passed through the conversion workflow and unsupported painting features cause failure and rollback

The provider preserves object identities and does not require a fixed source snapshot; LastReport returns the conversion report with an independent issue array

Reviewed existing structure repair

TPdfDocumentStructureRepairProvider handles parcStructure using reviewed TPdfStructureEditOperations and the SHA-256 digest of the original input snapshot

Construct the provider after ReadPdfDocumentStructure has supplied the digest and node IDs; use RepairPdfDocumentAFromBytes with those same original bytes

The provider checks the immutable base digest and stable identity state, then applies the reviewed operations to the current staged bytes; preceding identity-preserving color changes are supported

Node, text, source and output budgets are capped by parent limits; local and parent cancellation are checked before and after execution, and an available token is passed to the structure editor

LastReport returns an independent copy of inserted-node identities; the existing structure editor's restrictions and inherited-context checks still apply

Reviewed text resources

TPdfDocumentTextRepairProvider accepts a TPdfDocumentTextRepairPlan, options and one execution Category, default parcFonts; parcStructure and parcOther are also available for application-authored semantic plans

The selected category executes the complete supplied recipe once; split recipes into distinct providers when separate categories must perform different subsets

The constructor deep-copies font bytes, glyph maps, mapping-entry arrays and ActualText records after checking aggregate constructor budgets

The immutable base source digest and stable object-identity state must match; the current staged digest is supplied to the resource editor after these checks, permitting preceding identity-preserving repairs

Parent limits cap source/output, recipe count, per-font/per-stream and text budgets; local and parent cancellation are checked around the inner operation, with an available token used inside

LastReport returns the text-resource result; all concrete providers clear success/publication state if a final cancellation check fails

Postvalidation and scope

These providers retain the original object numbers and generations and return independent output; final built-in PDF/A checks run on exact bytes and the reopened native model

Only automatic, unblocked plan steps execute; reviewed or manual steps require an application decision before execution

These providers do not synthesize missing semantic content or invent fonts, character mappings or replacement text; the text provider requires explicit reviewed resource recipes

A successful built-in check is not external standards certification

See also

Document color conversion, Existing structure editing, Transactional repair