X-Ray.Content
26.9.4917
dotnet add package X-Ray.Content --version 26.9.4917
NuGet\Install-Package X-Ray.Content -Version 26.9.4917
<PackageReference Include="X-Ray.Content" Version="26.9.4917" />
<PackageVersion Include="X-Ray.Content" Version="26.9.4917" />
<PackageReference Include="X-Ray.Content" />
paket add X-Ray.Content --version 26.9.4917
#r "nuget: X-Ray.Content, 26.9.4917"
#:package X-Ray.Content@26.9.4917
#addin nuget:?package=X-Ray.Content&version=26.9.4917
#tool nuget:?package=X-Ray.Content&version=26.9.4917
<img src="logo.png" alt="X-Ray" width="160" align="right" />
X-Ray.Content
Content extraction for .NET. Point it at a document — Office, PDF, HTML, email, an archive — and get back the text, metadata, tables, images and a structured element tree, in whichever output format you ask for.
X-Ray.Content is the content-extraction package of the X-Ray family of .NET libraries.
The engine is a native C# port of the Rust xberg
extraction engine: every extractor, type and renderer is reimplemented in managed C#, not
wrapped over a native library.
Install
dotnet add package X-Ray.Content
The package id is hyphenated; the API lives under the XRay.Content namespace, since a hyphen is not
valid in a C# identifier.
Targets net10.0.
Extract a document
using XRay.Content.Core;
var extractor = new Extractor();
var result = extractor.Extract(
ExtractInput.FromUri("quarterly-report.pdf"),
new ExtractionConfig { OutputFormat = OutputFormat.Markdown });
var doc = result.Results[0];
Console.WriteLine(doc.MimeType); // application/pdf
Console.WriteLine(doc.Content); // the rendered Markdown
Console.WriteLine(doc.Metadata.Title);
Console.WriteLine(doc.Tables.Count);
Bytes work the same way when you already hold the file:
var input = ExtractInput.FromBytes(bytes, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
Extract never throws for a bad document: a failure lands in result.Errors with a type and
code, and an unsupported MIME type comes back as an empty document carrying a
ProcessingWarning. ExtractAsync is available for the same call.
Output formats
OutputFormat selects how ExtractedDocument.Content is rendered — the extracted document
model is the same either way:
| Format | Value |
|---|---|
| Plain text (default) | OutputFormat.Plain |
| Markdown (GFM) | OutputFormat.Markdown |
| HTML | OutputFormat.Html |
| Djot | OutputFormat.Djot |
| JSON section tree | OutputFormat.Json |
| Structured element list | OutputFormat.Structured |
| DocTags | OutputFormat.DocTags |
Set IncludeDocumentStructure = true to also get the Document heading tree, and
ResultFormat.ElementBased to get the flat element stream instead of one rendered string.
Formats it reads
Word, Excel, PowerPoint (modern and legacy binary), OpenDocument, RTF, WordPerfect, PDF, HTML/XML, Markdown/Djot/AsciiDoc/reStructuredText/Org/Typst/LaTeX, EPUB and FictionBook, email (EML, MSG, PST), iWork, HWP/HWPX, images (metadata and EXIF), CSV/TSV/DBF, JSON/YAML/TOML, BibTeX and citation formats, Jupyter notebooks, source code, and ZIP/TAR/7z/GZip archives (extracted recursively as child documents).
Optional OCR
Extraction is pure managed and pulls no native dependencies. OCR is the one exception, and it is off by default:
var config = new ExtractionConfig
{
Ocr = new OcrOptions { Mode = OcrMode.ScanOnly }, // or AllImages
};
ScanOnly recognises the PDF pages a scan detector flags; AllImages also reads every
embedded image and inserts its text inline after the image it came from. OCR is additive —
native text is never replaced — and never fatal: a missing checkpoint or an undecodable image
becomes a ProcessingWarning, not an exception.
Turning it on loads PaddleOCR, which brings
SkiaSharp and PDFium. A caller that never sets Ocr loads neither. Nothing is downloaded on
your behalf: point OcrOptions.ModelDirectory at a checkpoint you already have.
Links
- Source — the port lives under
dotnet/in thecuriosity-ai/x-ray-contentrepository - Architecture, scope and conventions
- Port status and work breakdown
- Issues
License
MIT AND Apache-2.0. The package is MIT, except for a handful of files that are derivative
works of Apache-2.0-only Rust crates and remain under that license — see
THIRD_PARTY_NOTICES.md
for exactly which files and which upstreams.
| Product | Versions 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. |
-
net10.0
- PaddleOCR (>= 26.8.4668)
- PaddleOCR.Pdf (>= 26.8.4668)
- SixLabors.Fonts (>= 2.0.9)
- SixLabors.ImageSharp (>= 3.1.11)
- System.Numerics.Tensors (>= 10.0.11)
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.9.4917 | 38 | 9/9/2026 |