Click or drag to resize
Pdf Library for .NET

PdfToTextGetWords Method

Returns every word of the document (respecting StartPageNumber / EndPageNumber) with the rectangle it covers and the font it is drawn in.

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntax
public PdfTextWord[] GetWords()

Return Value

PdfTextWord
The words of the pages, page by page in reading order; an empty array when they hold no text.
Remarks
The words are read the way GetText reads the text in Reading layout: columns one after the other, a right-to-left line from its right end, vertical writing as columns. Coordinates are in points from the top-left corner of the page, as for Search(String). ClipText applies: with it set, text outside the page is left out.
Example
PdfToText tool = new PdfToText();
tool.Load("document.pdf");
foreach (PdfTextWord word in tool.GetWords())
    if (word.FontSize >= 18)
        System.Console.WriteLine("page " + word.PageNumber + ": " + word.Text);
tool.Close();
See Also