Search Results for

    Show / Hide Table of Contents

    Class PdfClientTextExtensions

    Text structure helpers layered over IronSoftware.Pdfium.IPdfClient.

    Inheritance
    System.Object
    PdfClientTextExtensions
    Namespace: IronSoftware
    Assembly: IronPdf.dll
    Syntax
    public static class PdfClientTextExtensions : Object

    Structured text extraction from a PDF page becomes a single call when you use PdfClientTextExtensions, a static helper class that layers over IronSoftware.Pdfium.IPdfClient to return spatially organized text data. Rather than parsing raw character streams, you receive a ready-to-use IReadOnlyList<TextBlock> that groups characters into coherent blocks, preserving the reading order and layout geometry the underlying Pdfium engine detected.

    The single declared member, GetTextBlocks, is an extension method on IPdfClient. Pass the client handle, an IDocumentId identifying the open document, and a zero-based page_index, and the method returns all text blocks found on that page. Each TextBlock in the result carries positional and content information, making it straightforward to filter by region, sort by vertical position, or feed the data into a downstream text-processing pipeline. Because the return type is IReadOnlyList<TextBlock>, the collection is safe to enumerate multiple times without side effects.

    This class fits into the lower-level Pdfium layer of IronPDF, sitting alongside other IPdfClient-oriented utilities rather than the higher-level PdfDocument API. It is the right tool when you need precise, block-level text coordinates from a specific page, for example when building a table extractor, a redaction tool, or a content-search index.

    using IronSoftware;
    
    IReadOnlyList<TextBlock> blocks = client.GetTextBlocks(documentId, pageIndex: 0);
    foreach (TextBlock block in blocks)
        Console.WriteLine(block.Text);

    The IronPDF text extraction how-to covers common extraction patterns, and the IronPDF examples show end-to-end scenarios.

    Methods

    GetTextBlocks(IPdfClient, IDocumentId, Int32)

    Groups a page's text fragments into PyMuPDF-style blocks, lines and spans.

    Lines are grouped by baseline Y. Text rotated away from the horizontal is returned one fragment per line, each in its own block after the horizontal text. See SpanOrigin.

    Grouping has no horizontal-gap check, so multiple columns or table cells sharing a baseline are returned as a single line/block.

    Declaration
    public static IReadOnlyList<TextBlock> GetTextBlocks(this IPdfClient client, IDocumentId id, int page_index)
    Parameters
    Type Name Description
    IronSoftware.Pdfium.IPdfClient client

    PDF client

    IronSoftware.Abstractions.Pdf.IDocumentId id

    Document identifier

    System.Int32 page_index

    Zero based page index

    Returns
    Type Description
    System.Collections.Generic.IReadOnlyList<TextBlock>

    Blocks in reading order, top of page first.

    Exceptions
    Type Condition
    System.ArgumentNullException

    client or id is null.

    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget