 |
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 HierarchySystemObject
SelectPdf.UniversalPdfTextWord
Namespace: SelectPdf.UniversalAssembly: SelectPdf.Universal (in SelectPdf.Universal.dll) Version: 26.6
SyntaxThe PdfTextWord type exposes the following members.
Constructors
Properties| | Name | Description |
|---|
 | FontName |
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+).
|
 | FontSize | Gets the size of the font the word is drawn in, in points. |
 | Height | Gets the height of the word's rectangle, in points. |
 | PageNumber |
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]).
|
 | Rotation |
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.
|
 | SpaceAfter |
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.
|
 | Text |
Gets the text of the word. A right-to-left word (Arabic, Hebrew) is in logical order, the order it is
read in.
|
 | Width | Gets the width of the word's rectangle, in points. |
 | X | Gets the X coordinate of the word's rectangle, in points from the left edge of the page. |
 | Y | Gets the Y coordinate of the word's rectangle, in points from the top edge of the page. |
Top
Methods| | Name | Description |
|---|
 | ToString | Returns 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.
ExamplePdfToText 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();Dim tool As New PdfToText()
tool.Load("document.pdf")
For Each word As PdfTextWord In tool.GetWords(1)
System.Console.WriteLine(word.Text & " at (" & word.X & ", " & word.Y & ") in " &
word.FontName & " " & word.FontSize & "pt")
Next
tool.Close()
See Also