TPDFContentFilterChain

Content streams

Description

TPDFContentFilterChain (unit Lib\PDFlibContentFilter.pas, added in v3.516.0) is an ordered chain of filter callbacks applied to every content layer of a page during an instruction-level content transformation

Each filter receives the layer's parsed TPDFContentProgram and may insert, delete or modify instructions directly before the program is serialised back; create a chain with NewContentFilterChain and run it with ApplyContentFilterChain or ApplyContentFilterChainExt

Syntax

Delphi

TPDFContentFilterCallback = Function(Program_: TPDFContentProgram;
  Const LayerName: AnsiString; FilterData: Pointer): TPDFContentFilterResult;

TPDFContentFilterChain = Class
  Public
    Function Count: Integer;
    Procedure Add(Callback: TPDFContentFilterCallback; FilterData: Pointer = Nil);
    Procedure Clear;
    Function Apply(Program_: TPDFContentProgram;
      Const LayerName: AnsiString): Boolean;
  End;

Key members

AddRegisters one callback with an optional caller-defined FilterData pointer that is passed through unchanged
CountNumber of registered filters
ClearDrops every registered filter
ApplyRuns every filter in registration order on one program; returns False when any filter returned cfrStop

Remarks

A callback returns cfrContinue to proceed or cfrStop to short-circuit the remaining filters and layers; returning cfrStop is also how a chain aborts a multi-layer pass early

The batch model hands each filter the full instruction list, so sliding-window patterns such as colour-operator sequences stay trivially expressible; the caller owns the chain and must free it

See also

NewContentFilterChain, ApplyContentFilterChain, ApplyContentFilterChainExt, TPDFContentProgram