PDFium Delphi Component Docs

TextPageSnapshot property

Component: TPdf  ·  Unit: PDFium
Returns the cached bounded text snapshot of one page with page text, character records and text object records

Syntax

property TextPageSnapshot[PageNumber: Integer]: TPdfTextPageSnapshot; // read only

 

type TPdfTextPageSnapshot = record
  PageNumber: Integer;
  Width: Double;
  Height: Double;
  Status: TPdfTextSnapshotStatus;
  Text: WString;
  Characters: TPdfTextCharacterSnapshots;
  TextObjects: TPdfTextObjectSnapshots;
end;

PageNumberInteger. One-based page index within the loaded document
StatusTPdfTextSnapshotStatus. Completion flag, visited counts, unmapped and failure counters, and the budget flags that were reached
TextWString. Extracted page text in native PDFium order
CharactersPer-character records with code point, indices, bounds, origin, angle, font size, colours and matrix facts
TextObjectsPer-text-object records with character ranges, font name, flags, weight and render mode

Description

The first access for a page captures the snapshot with TPdfTextSnapshotOptions.Default budgets, one million characters, one hundred thousand text objects and a 16 MiB font name budget. The active page is read through its loaded handles, and any other page is loaded and closed transiently without changing PageNumber or firing OnPageChange

Every access returns a deep copy, so changing a caller-owned string or array cannot modify the cached snapshot or the PDF

Completed snapshots are retained in the bounded cache described by TextSnapshotCacheCapacity and measured against CacheBudgetBytes, and GetStructuredText plus physical-layout GetTextInReadingOrder reuse the same snapshot

Remarks

Calling without an active document raises EPdfError, and a PageNumber outside one to PageCount raises EPdfError with the message Incorrect page number

Use ReadTextPageSnapshot for custom capture budgets or to bypass the cache deliberately

Example

Snapshot := Pdf.TextPageSnapshot[PageNumber];
if Snapshot.Status.Completed then
  LogCharacterCount(Length(Snapshot.Characters));

See Also

TextSnapshotCacheCapacity, TextSnapshotCacheCount, TextPageSnapshots, GetStructuredText, TPdfView.TextPage