PdfWord.Rectangles Property
Returns rectangles surrounding the word.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
public IList<PdfOrientedRectangle> Rectangles { get; }
#Property Value
Type | Description |
---|---|
IList<Pdf |
A collection of Pdf |
#Remarks
Tip
The Rectangles
property returns more than one Pdf
// Declare a list to store the word and its coordinates
List<Tuple<string, PdfOrientedRectangle>> WordCoordinates = new List<Tuple<string, PdfOrientedRectangle>>();
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
processor.LoadDocument("Document.pdf");
PdfPageWord currentWord = processor.NextWord();
while (currentWord != null)
{
for (int i = 0; i < currentWord.Rectangles.Count; i++)
{
// Retrieve the number of the page on which the word
// is located:
int pageNumber = currentWord.PageNumber;
// Retrieve the rectangle encompassing the word
var wordRectangle = currentWord.Rectangles[i];
// Add the segment's content and its coordinates to the list
WordCoordinates.Add(new Tuple<string, PdfOrientedRectangle>(currentWord.Segments[i].Text, wordRectangle));
}
// Switch to the next word
currentWord = processor.NextWord();
}
}