Microsoft.Extensions.DocumentExtraction.Abstractions 11.0.1-preview.1.26570.2

Prefix Reserved
This is a prerelease version of Microsoft.Extensions.DocumentExtraction.Abstractions.
dotnet add package Microsoft.Extensions.DocumentExtraction.Abstractions --version 11.0.1-preview.1.26570.2
                    
NuGet\Install-Package Microsoft.Extensions.DocumentExtraction.Abstractions -Version 11.0.1-preview.1.26570.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Extensions.DocumentExtraction.Abstractions" Version="11.0.1-preview.1.26570.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Extensions.DocumentExtraction.Abstractions" Version="11.0.1-preview.1.26570.2" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Extensions.DocumentExtraction.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Extensions.DocumentExtraction.Abstractions --version 11.0.1-preview.1.26570.2
                    
#r "nuget: Microsoft.Extensions.DocumentExtraction.Abstractions, 11.0.1-preview.1.26570.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.Extensions.DocumentExtraction.Abstractions@11.0.1-preview.1.26570.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.Extensions.DocumentExtraction.Abstractions&version=11.0.1-preview.1.26570.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.Extensions.DocumentExtraction.Abstractions&version=11.0.1-preview.1.26570.2&prerelease
                    
Install as a Cake Tool

Microsoft.Extensions.DocumentExtraction.Abstractions

Extract structured content through a common .NET client contract, without tying your application to a particular provider SDK. DocumentExtractionClient accepts a document Stream and returns a completed ExtractionDocument containing text, images, tables and sections.

This package defines the client, per-call options and a base for delegating middleware. It does not include an OCR engine or a provider implementation. Choose a provider that supports your document formats and environment.

Use the companion Microsoft.Extensions.DocumentExtraction package if you also want pipeline builders, logging and dependency-injection registration. If you only need to construct or consume the document graph, use Microsoft.Extensions.Documents.Abstractions.

Install

dotnet add package Microsoft.Extensions.DocumentExtraction.Abstractions --prerelease

Install your chosen provider separately and follow its configuration requirements.

The direct dependency is Microsoft.Extensions.Documents.Abstractions, which uses Microsoft.Extensions.AI.Abstractions for content payloads. Prefer .NET 8 or later. Compatibility assets for .NET Framework and .NET Standard do not guarantee support for every older runtime; check package compatibility and your provider's requirements.

Extract a document

This application helper takes an already configured provider client. It opens and disposes the input file; the caller retains responsibility for the client's lifetime. The media type must be supported by that provider.

using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DocumentExtraction;
using Microsoft.Extensions.Documents;

public static class ExtractDocument
{
    public static async Task<ExtractionDocument> RunAsync(
        DocumentExtractionClient client, string path, string mediaType,
        CancellationToken cancellationToken = default)
    {
        using FileStream input = File.OpenRead(path);
        ExtractionDocument result = await client.ExtractAsync(
            input, Path.GetFileName(path), mediaType,
            cancellationToken: cancellationToken);

        foreach (ExtractionDocumentElement element in result.EnumerateContent())
        {
            if (element is ExtractionDocumentTextElement text &&
                text.Content is TextContent content)
            {
                Console.WriteLine(content.Text);
            }
        }

        return result;
    }
}

The identifier names the input; it does not fetch a file or URI. The task returns one completed document, not a stream of partial results. EnumerateContent() walks non-section elements in document order. Inspect the hierarchy directly for table cells and document/section-local payloads.

Select an extractor

ExtractorName selects an extractor or analyzer within the configured provider; null uses its default. Use a selector that your provider documents as supported. AdditionalProperties accepts provider-specific settings whose names and types are defined by that provider, not by this package.

This alternative helper accepts an existing stream and leaves it open:

using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DocumentExtraction;
using Microsoft.Extensions.Documents;

public static class SelectExtractor
{
    public static Task<ExtractionDocument> RunAsync(
        DocumentExtractionClient client, Stream input, string mediaType,
        string supportedSelector, CancellationToken cancellationToken = default)
    {
        var options = new DocumentExtractionOptions
        {
            ExtractorName = supportedSelector
        };
        return client.ExtractAsync(
            input, "document", mediaType, options, cancellationToken);
    }
}

Unsupported explicit settings should be rejected rather than silently ignored. Do not mutate options or their referenced values while a call is in progress. Clone() creates a separate options container, but does not deep-clone values in AdditionalProperties.

Implement a local client

Implement DocumentExtractionClient when adapting another extraction library. This optional, self-contained example only decodes plain text into one section: it does not perform OCR or parse PDFs. It preserves the input stream and rejects settings it does not support.

using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DocumentExtraction;
using Microsoft.Extensions.Documents;

public sealed class PlainTextExtractionClient : DocumentExtractionClient
{
    public override async Task<ExtractionDocument> ExtractAsync(
        Stream document, string identifier, string mediaType,
        DocumentExtractionOptions? options = null,
        CancellationToken cancellationToken = default)
    {
        ArgumentNullException.ThrowIfNull(document);
        ArgumentException.ThrowIfNullOrEmpty(identifier);
        ArgumentException.ThrowIfNullOrEmpty(mediaType);
        if (!string.Equals(mediaType, "text/plain", StringComparison.OrdinalIgnoreCase))
        {
            throw new NotSupportedException("This example accepts only text/plain.");
        }

        DocumentExtractionOptions? settings = options?.Clone();
        if (settings?.ExtractorName is not null ||
            settings?.AdditionalProperties.Count > 0)
        {
            throw new NotSupportedException("This example has no configurable extractor settings.");
        }

        cancellationToken.ThrowIfCancellationRequested();
        using var reader = new StreamReader(
            document, Encoding.UTF8, detectEncodingFromByteOrderMarks: true,
            bufferSize: 1024, leaveOpen: true);
        string text = await reader.ReadToEndAsync(cancellationToken);

        var result = new ExtractionDocument(identifier);
        var section = new ExtractionDocumentSection();
        section.Elements.Add(new ExtractionDocumentTextElement(new TextContent(text)));
        result.Sections.Add(section);
        return result;
    }
}

Ownership, cancellation and errors

Callers own input streams. Returned documents are non-disposable data. Optional native objects exposed through RawRepresentation or source references are borrowed, may be unavailable, and are not automatically disposed or safe to log. Native access does not guarantee original response bytes.

Pass a cancellation token to the operation; cancellation support and format errors depend on the selected provider. Providers are responsible for releasing their own resources on success, failure and cancellation without disposing caller-owned streams or borrowed native objects.

Extraction APIs are experimental under MEDE0001; the Documents model uses EXTEXP0019. Acknowledge these diagnostics only if you accept experimental APIs.

Feedback

Report contract issues through dotnet/extensions issues. For supported formats, credentials and provider-specific errors, consult the provider's documentation and issue tracker.

Supported Platforms

This package includes .NET Framework compatible targets, but is not officially supported on .NET Framework.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Microsoft.Extensions.DocumentExtraction.Abstractions:

Package Downloads
Microsoft.Extensions.DocumentExtraction

Experimental package. Middleware and dependency-injection utilities for document extraction.

CommunityToolkit.DocumentExtraction.VisionLanguageModel

Vision language model extraction through an application-supplied Microsoft.Extensions.AI IChatClient. The adapter, API and model must support original PDF/image inputs; structured extraction also requires schema-based responses.

CommunityToolkit.DocumentExtraction.Mistral

Native Mistral OCR document extraction through direct Mistral or Microsoft Foundry endpoints.

CommunityToolkit.DocumentExtraction.PdfPig

Native PDF text extraction for Microsoft.Extensions.DocumentExtraction.

CommunityToolkit.DocumentExtraction.AzureDocumentIntelligence

Azure Document Intelligence extraction for Microsoft.Extensions.DocumentExtraction.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.1-preview.1.26570.2 53 11/21/2026
11.0.0-preview.1.26560.3 276 11/10/2026