Table of Contents

Class PdfTextPage

Namespace
PdfEngine.Vector.Text
Assembly
PdfEngine.Vector.dll

A page's text the way a reader's text layer has it: characters in reading order, with the spaces and line breaks the layout implies, a box per character and the page text as one string. It follows PDFium's text page (CPDF_TextPage) rule for rule, so that search, selection and copy behave as they did with PDFium: content order within a line, lines ordered by position, objects drawn twice for a bold effect dropped, spaces generated from gaps between glyphs and objects, "\r\n" between lines, line-end hyphens marked, ligatures (U+FB00–FB06) split, /ActualText in place of the glyphs it covers, right-to-left runs reversed. Boxes are in default user space (the page's own coordinates, not offset by its crop box, unrotated).

public sealed class PdfTextPage
Inheritance
PdfTextPage
Inherited Members

Properties

CharCount

Number of characters, generated ones included.

public int CharCount { get; }

Property Value

int

PageBox

The page's box in user space: the crop box within the media box (where normalized coordinates start).

public PdfRect PageBox { get; }

Property Value

PdfRect

PageNumber

1-based page number.

public int PageNumber { get; }

Property Value

int

Rotation

The page's /Rotate in degrees (0, 90, 180, 270).

public int Rotation { get; }

Property Value

int

Text

The page text: every character that reads as text, in order (line breaks as "\r\n").

public string Text { get; }

Property Value

string

Methods

CharIndexFromTextIndex(int)

public int CharIndexFromTextIndex(int textIndex)

Parameters

textIndex int

Returns

int

Find(string, bool, bool, bool)

Every match of query on the page as (first character, character count), with PDFium's search rules (FPDFText_FindStart/FindNext): words of the query match across any run of spaces and line breaks, CJK characters match one by one, "match whole word" rejects letters and digits next to the match.

public IReadOnlyList<(int Start, int Count)> Find(string query, bool matchCase = false, bool matchWholeWord = false, bool consecutive = false)

Parameters

query string
matchCase bool
matchWholeWord bool
consecutive bool

Returns

IReadOnlyList<(int Start, int Count)>

GetAllText()

The whole page text (all characters).

public string GetAllText()

Returns

string

GetCharBox(int)

The character's glyph box (its ink, from the font's outline) in user space.

public PdfTextRect GetCharBox(int index)

Parameters

index int

Returns

PdfTextRect

GetCharType(int)

public PdfTextCharType GetCharType(int index)

Parameters

index int

Returns

PdfTextCharType

GetFontSize(int)

The font size of the text the character belongs to; 0 for a generated character.

public double GetFontSize(int index)

Parameters

index int

Returns

double

GetLooseCharBox(int)

The character's box from the font box (ascent to descent, so a line's characters line up), in user space.

public PdfTextRect GetLooseCharBox(int index)

Parameters

index int

Returns

PdfTextRect

GetMarkedContentId(int)

The marked-content identifier (MCID) of the text the character belongs to, or -1 (none, or a generated character).

public int GetMarkedContentId(int index)

Parameters

index int

Returns

int

GetOrigin(int)

Where the glyph is drawn from, in user space.

public PdfPoint GetOrigin(int index)

Parameters

index int

Returns

PdfPoint

GetText(int, int)

The text of characters [start, start + count), as PDFium's FPDFText_GetText returns it.

public string GetText(int start, int count)

Parameters

start int
count int

Returns

string

GetUnicode(int)

public char GetUnicode(int index)

Parameters

index int

Returns

char

HasTextObject(int)

True when the character belongs to a text object (it is not a generated space or line break).

public bool HasTextObject(int index)

Parameters

index int

Returns

bool

IsGenerated(int)

public bool IsGenerated(int index)

Parameters

index int

Returns

bool

IsHyphen(int)

public bool IsHyphen(int index)

Parameters

index int

Returns

bool

TextIndexFromCharIndex(int)

public int TextIndexFromCharIndex(int charIndex)

Parameters

charIndex int

Returns

int