OnInlineImageBoundary

Content stream editing

Description

Event property that replaces the built-in heuristic for locating the end of an inline image during Parse. Unassigned, Parse proves the BI..EI boundary from the image dictionary's declared width, height, bits per component, colour space and filter, and falls back to scanning for a whitespace-delimited EI token when that proof is inconclusive. Assigning a handler opts into an exact boundary proof supplied by the application.

The handler fires once for every BI keyword the tokenizer meets, before any instruction is emitted for that image. When it proves a boundary, Parse captures the entire BI..EI slice verbatim as one coBeginImage instruction whose RawInlineImage field carries the raw bytes, and resumes parsing after the EI.

Syntax

Delphi

Property TPDFContentProgram.OnInlineImageBoundary: TPDFInlineBoundaryEvent;

Parameters

SourceHandler parameter: the complete content stream being parsed; all positions index it one-based
BIStartHandler parameter: one-based index of the BI keyword in Source
AfterEIHandler out parameter: one-based position just past the terminating EI

Return values

TrueHandler result: the boundary is proven and AfterEI is used
FalseHandler result: the capture fails and Parse stops with False

Remarks

The handler type is TPDFInlineBoundaryEvent = Function(Const Source: AnsiString; BIStart: Integer; Out AfterEI: Integer): Boolean Of Object. Assign it before calling Parse; the property is only consulted while parsing.

The returned boundary is validated: AfterEI must lie more than four bytes past BIStart, at most one position beyond the stream, and the two bytes preceding it must read EI. A boundary that fails validation also aborts the parse with False.

See also

Parse, ReplaceInlineImage, TPDFContentProgram, TPDFContentInstruction, CanonicalNumbers