Click or drag to resize
Pdf Library for .NET

PdfTextWord Class

A word of a PDF page, as returned by GetWords: its text, the rectangle it covers and the font it is drawn in.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfTextWord

Namespace: SelectPdf.Universal
Assembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
Syntax
public class PdfTextWord

The PdfTextWord type exposes the following members.

Constructors
 NameDescription
Public methodPdfTextWord 
Top
Properties
 NameDescription
Public propertyFontName Gets the name of the font the word is drawn in, as the PDF document names it (for example Arial-BoldMT), without the prefix that marks an embedded subset (ABCDEF+).
Public propertyFontSizeGets the size of the font the word is drawn in, in points.
Public propertyHeightGets the height of the word's rectangle, in points.
Public propertyPageNumber Gets the 1-based number of the page the word is on (note PdfPageCollection is zero-based, so this maps to doc.Pages[PageNumber - 1]).
Public propertyRotation Gets the direction the word runs in, in degrees clockwise: 0 for ordinary horizontal text, 90 for text running down the page (vertical writing, or a page turned sideways), 180 for upside-down text and 270 for text running up the page.
Public propertySpaceAfter Gets a value indicating whether the word is followed by a space, or ends its line. Joining the words of a page with a space after each word that has one gives the page's text.
Public propertyText Gets the text of the word. A right-to-left word (Arabic, Hebrew) is in logical order, the order it is read in.
Public propertyWidthGets the width of the word's rectangle, in points.
Public propertyXGets the X coordinate of the word's rectangle, in points from the left edge of the page.
Public propertyYGets the Y coordinate of the word's rectangle, in points from the top edge of the page.
Top
Methods
 NameDescription
Public methodToStringReturns the text of the word.
(Overrides ObjectToString)
Top
Remarks
Coordinates are in points from the top-left corner of the page, as for TextPosition, so a word and a Search(String) hit on the same text cover the same rectangle.
Example
PdfToText tool = new PdfToText();
tool.Load("document.pdf");
foreach (PdfTextWord word in tool.GetWords(1))
    System.Console.WriteLine(word.Text + " at (" + word.X + ", " + word.Y + ") in " +
        word.FontName + " " + word.FontSize + "pt");
tool.Close();
See Also