CharInfoCollection

CharInfoCollection class

Represents CharInfo objects collection.

public sealed class CharInfoCollection : ICollection<CharInfo>

Properties

Name Description
Count { get; } Gets the number of CharInfo object elements actually contained in the collection.
IsReadOnly { get; } Gets a value indicating whether collection is read-only
IsSynchronized { get; } Gets a value indicating whether access to the collection is synchronized (thread safe).
Item { get; } Gets the CharInfo element at the specified index.
SyncRoot { get; } Gets an object that can be used to synchronize access to the collection.

Methods

Name Description
Add(CharInfo) Collection is read-only, throws NotImplementedException.
Clear() Collection is read-only. Always throws NotImplementedException.
Contains(CharInfo) Determines whether the collection contains a specific value.
CopyTo(CharInfo[], int) Copies the entire collection to a compatible one-dimensional Array, starting at the specified index of the target array
GetEnumerator() Returns an enumerator for the entire collection.
Remove(CharInfo) Collection is read-only, throws NotImplementedException.

Remarks

Provides access to positioning information of text segment characters.

Examples

The example demonstrates how to iterate throught all the characters and retrieve the charact

//open document
Document pdfDocument = new Document(inFile);
//create TextFragmentAbsorber object to collect all the text objects of the page
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
//accept the absorber for all the pages
pdfDocument.Pages[1].Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;
            
//loop through the fragments
foreach (TextFragment textFragment in textFragmentCollection)
{
    //loop through the segments
    foreach (TextSegment textSegment in textFragment.Segments)
    {
        //loop through the characters
        for (int i = 1; i <= textSegment.Text.Length; i++)
        {
            CharInfo charInfo = textSegment.Characters[i];

            // print character position and rectangle info
            Console.WriteLine("XIndent : {0} ", charInfo.Position.XIndent);
            Console.WriteLine("YIndent : {0} ", charInfo.Position.YIndent);
            Console.WriteLine("Width : {0} ", charInfo.Rectangle.Width);
            Console.WriteLine("Height : {0} ", charInfo.Rectangle.Height);
        }
    }
}

See Also