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
| Source | Handler parameter: the complete content stream being parsed; all positions index it one-based |
|---|---|
| BIStart | Handler parameter: one-based index of the BI keyword in Source |
| AfterEI | Handler out parameter: one-based position just past the terminating EI |
Return values
| True | Handler result: the boundary is proven and AfterEI is used |
|---|---|
| False | Handler 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