Class PdfTextPage
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
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
PageNumber
1-based page number.
public int PageNumber { get; }
Property Value
Rotation
The page's /Rotate in degrees (0, 90, 180, 270).
public int Rotation { get; }
Property Value
Text
The page text: every character that reads as text, in order (line breaks as "\r\n").
public string Text { get; }
Property Value
Methods
CharIndexFromTextIndex(int)
public int CharIndexFromTextIndex(int textIndex)
Parameters
textIndexint
Returns
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
Returns
- IReadOnlyList<(int Start, int Count)>
GetAllText()
The whole page text (all characters).
public string GetAllText()
Returns
GetCharBox(int)
The character's glyph box (its ink, from the font's outline) in user space.
public PdfTextRect GetCharBox(int index)
Parameters
indexint
Returns
GetCharType(int)
public PdfTextCharType GetCharType(int index)
Parameters
indexint
Returns
GetFontSize(int)
The font size of the text the character belongs to; 0 for a generated character.
public double GetFontSize(int index)
Parameters
indexint
Returns
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
indexint
Returns
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
indexint
Returns
GetOrigin(int)
Where the glyph is drawn from, in user space.
public PdfPoint GetOrigin(int index)
Parameters
indexint
Returns
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
Returns
GetUnicode(int)
public char GetUnicode(int index)
Parameters
indexint
Returns
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
indexint
Returns
IsGenerated(int)
public bool IsGenerated(int index)
Parameters
indexint
Returns
IsHyphen(int)
public bool IsHyphen(int index)
Parameters
indexint
Returns
TextIndexFromCharIndex(int)
public int TextIndexFromCharIndex(int charIndex)
Parameters
charIndexint