X-Ray.DocumentExtraction 26.11.8565-preview

This is a prerelease version of X-Ray.DocumentExtraction.
dotnet add package X-Ray.DocumentExtraction --version 26.11.8565-preview
                    
NuGet\Install-Package X-Ray.DocumentExtraction -Version 26.11.8565-preview
                    
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="X-Ray.DocumentExtraction" Version="26.11.8565-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="X-Ray.DocumentExtraction" Version="26.11.8565-preview" />
                    
Directory.Packages.props
<PackageReference Include="X-Ray.DocumentExtraction" />
                    
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 X-Ray.DocumentExtraction --version 26.11.8565-preview
                    
#r "nuget: X-Ray.DocumentExtraction, 26.11.8565-preview"
                    
#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 X-Ray.DocumentExtraction@26.11.8565-preview
                    
#: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=X-Ray.DocumentExtraction&version=26.11.8565-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=X-Ray.DocumentExtraction&version=26.11.8565-preview&prerelease
                    
Install as a Cake Tool

X-Ray.DocumentExtraction

X-Ray

A provider for Microsoft.Extensions.DocumentExtraction, the .NET document extraction abstraction (DocumentExtractionClient), backed by X-Ray.Content. Give it a stream and a media type, get back the provider-neutral ExtractionDocument: nested sections, headings, text, tables with addressable cells, images, and page references with regions. Any code written against the abstraction, such as middleware, the data ingestion pipeline or a provider-switching host, can use X-Ray.Content's 90+ formats without knowing about it.

The default path is pure managed code and calls no service. OCR is available through X-Ray.Content's opt-in pass and is off unless you configure it.

Preview. The abstraction is experimental (EXTEXP0019, MEDE0001) and this package is published with a -preview version suffix. Expect changes when the abstraction changes.

Install

dotnet add package X-Ray.DocumentExtraction --prerelease

The namespace is XRay.DocumentExtraction. For middleware (UseLogging, the builder, dependency injection helpers) also add Microsoft.Extensions.DocumentExtraction.

Quick start

using Microsoft.Extensions.AI;
using Microsoft.Extensions.DocumentExtraction;
using Microsoft.Extensions.Documents;
using XRay.DocumentExtraction;

DocumentExtractionClient client = new XRayDocumentExtractionClient();

await using var file = File.OpenRead("report.docx");
ExtractionDocument document = await client.ExtractAsync(
    file,
    "report.docx",
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    cancellationToken: CancellationToken.None);

foreach (var element in document.EnumerateContent())
{
    switch (element)
    {
        case ExtractionDocumentTextElement { Content: TextContent text } t:
            Console.WriteLine($"{t.Role ?? "text"}: {text.Text}");
            break;
        case ExtractionDocumentTableElement table:
            Console.WriteLine($"table {table.Cells.RowCount} x {table.Cells.ColumnCount}");
            break;
    }
}

Configuration

var client = new XRayDocumentExtractionClient(new XRayDocumentExtractionOptions
{
    IncludeImageBytes = true,
    Configure = config => config.Pdf.Password = "secret",
});

Configure receives X-Ray.Content's ExtractionConfig once, at construction. The client always turns on the document structure, which the mapping reads.

What maps to what

X-Ray.Content Abstraction
Title text element, role title
Heading, level n section opened at level n, first element a text element with role heading and HeadingLevel n
Slide section with the slide's title
Paragraph text element
List item, code, formula, footnote text element, roles listItem, code, formula, footnote
Header and footer layers text element, roles pageHeader and pageFooter
Table table element: cells with row and column spans, role columnHeader or content
Image image element: alternative text, source, bytes with IncludeImageBytes
Page number and bounding box source reference: a page (page-N) and the box as a four-point polygon
Title, authors, dates, language ExtractionDocument.Metadata

The native result is on RawRepresentation (an XRay.Content.Types.ExtractedDocument) for anything the abstraction does not model.

Errors: a format without an extractor throws NotSupportedException; a document that cannot be read throws InvalidDataException; a cancelled token throws OperationCanceledException. DocumentExtractionOptions.ExtractorName is rejected, since the provider has one extractor.

Licence

MIT AND Apache-2.0, the expression of X-Ray.Content, whose code this package runs.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.11.8565-preview 0 11/26/2026