OxidizePdf.NET
0.14.0
See the version list below for details.
dotnet add package OxidizePdf.NET --version 0.14.0
NuGet\Install-Package OxidizePdf.NET -Version 0.14.0
<PackageReference Include="OxidizePdf.NET" Version="0.14.0" />
<PackageVersion Include="OxidizePdf.NET" Version="0.14.0" />
<PackageReference Include="OxidizePdf.NET" />
paket add OxidizePdf.NET --version 0.14.0
#r "nuget: OxidizePdf.NET, 0.14.0"
#:package OxidizePdf.NET@0.14.0
#addin nuget:?package=OxidizePdf.NET&version=0.14.0
#tool nuget:?package=OxidizePdf.NET&version=0.14.0
OxidizePdf.NET
.NET bindings for oxidize-pdf - Fast, memory-safe PDF text extraction optimized for RAG/LLM pipelines with intelligent chunking.
Features
- π High Performance - Native Rust speed (3,000-4,000 pages/second)
- π§ AI/RAG Optimized - Intelligent text chunking with sentence boundaries
- π‘οΈ Memory Safe - Zero-copy FFI with automatic resource management
- π Cross-Platform - Linux, Windows, macOS (x64)
- π¦ Zero Dependencies - Self-contained native binaries in NuGet package
- π Metadata Rich - Page numbers, confidence scores, bounding boxes
Installation
dotnet add package OxidizePdf.NET
Quick Start
Basic Text Extraction
using OxidizePdf.NET;
// Extract all text from PDF
using var extractor = new PdfExtractor();
byte[] pdfBytes = File.ReadAllBytes("document.pdf");
string text = await extractor.ExtractTextAsync(pdfBytes);
Console.WriteLine(text);
RAG Extraction (recommended)
OxidizePdf.NET mirrors the RAG-first surface of the Python bridge
(oxidize-python). Token-aware, structure-aware chunks ready for vector
store ingestion in one call:
using OxidizePdf.NET;
using OxidizePdf.NET.Pipeline;
var extractor = new PdfExtractor();
var chunks = await extractor.RagChunksAsync(pdfBytes, ExtractionProfile.Rag);
foreach (var c in chunks)
{
// c.FullText β text + heading context (use this for embeddings)
// c.Text β the chunk's own text
// c.PageNumbers β 1-based source pages (cite results)
// c.TokenEstimate β plan batch sizes / model windows
// c.HeadingContext β section heading the chunk belongs to (or null)
}
Seven profiles: Standard, Academic, Form, Government, Dense,
Presentation, Rag. For fine-grained control pass an explicit
PartitionConfig (reading order, header/footer zones, table confidence)
and/or HybridChunkConfig (max tokens, overlap, merge policy):
var partition = new PartitionConfig()
.WithReadingOrder(ReadingOrderStrategy.XyCut(20.0)) // multi-column
.WithMinTableConfidence(0.7);
var hybrid = new HybridChunkConfig().WithMaxTokens(256).WithOverlap(32);
var chunks = await extractor.RagChunksAsync(pdfBytes, partition, hybrid);
Element-aware semantic chunks (titles/tables kept whole):
var semantic = await extractor.SemanticChunksAsync(
pdfBytes,
new SemanticChunkConfig(maxTokens: 512));
Markdown export with explicit options (RAG-012):
using OxidizePdf.NET.Ai;
var md = await extractor.ToMarkdownAsync(
pdfBytes,
new MarkdownOptions { IncludeMetadata = true, IncludePageNumbers = true });
Standalone text chunker (no PDF β for non-PDF sources):
using OxidizePdf.NET.Ai;
var chunker = new DocumentChunker(chunkSize: 512, overlap: 50);
var pieces = chunker.ChunkText(rawText);
var tokens = DocumentChunker.EstimateTokens(rawText);
End-to-end vector-store ingestion with KernelMemory:
using OxidizePdf.NET;
using OxidizePdf.NET.Pipeline;
using Microsoft.KernelMemory;
var extractor = new PdfExtractor();
var memory = new KernelMemoryBuilder().Build();
var chunks = await extractor.RagChunksAsync(pdfBytes, ExtractionProfile.Rag);
foreach (var c in chunks)
{
await memory.ImportTextAsync(
text: c.FullText,
documentId: $"doc_p{c.PageNumbers[0]}_c{c.ChunkIndex}",
tags: new Dictionary<string, object>
{
["source"] = "SharePoint/Documents/report.pdf",
["pages"] = string.Join(",", c.PageNumbers),
["heading"] = c.HeadingContext ?? string.Empty,
["tokens"] = c.TokenEstimate,
});
}
Legacy character-based chunking (
ChunkOptions+ExtractChunksAsync) is marked[Obsolete]since 0.9.0-rag.1 and will be removed one minor release later. Prefer the token-aware overloads above.
SharePoint Crawler Example
using OxidizePdf.NET;
using Microsoft.Graph;
var extractor = new PdfExtractor();
var graphClient = new GraphServiceClient(...);
// Crawl SharePoint document library
var driveItems = await graphClient.Sites["root"]
.Drives["Documents"]
.Root
.Children
.Request()
.Filter("endsWith(name,'.pdf')")
.GetAsync();
foreach (var item in driveItems)
{
var stream = await graphClient.Sites["root"]
.Drives["Documents"]
.Items[item.Id]
.Content
.Request()
.GetAsync();
using var ms = new MemoryStream();
await stream.CopyToAsync(ms);
var chunks = await extractor.ExtractChunksAsync(ms.ToArray());
// Process chunks for embeddings...
}
Performance
Based on oxidize-pdf v1.6.4 benchmarks:
- Text Extraction: 3,000-4,000 pages/second
- Chunking: 0.62ms for 100 pages
- Memory Overhead: <1MB per document
- PDF Parsing: 98.8% success rate on 759 real-world PDFs
Supported Platforms
| Platform | Runtime Identifier | Status |
|---|---|---|
| Linux x64 | linux-x64 |
β Supported |
| Windows x64 | win-x64 |
β Supported |
| macOS x64 | osx-x64 |
β Supported |
Native binaries are automatically included in the NuGet package.
Architecture
- native/ - Rust FFI layer (cdylib)
- dotnet/ - C# wrapper with P/Invoke
- examples/ - Integration examples (KernelMemory, BasicUsage)
See ARCHITECTURE.md for detailed design decisions.
API Reference
PdfExtractor
public class PdfExtractor : IDisposable
{
// Extract plain text from PDF
public Task<string> ExtractTextAsync(byte[] pdfBytes);
// Extract text chunks optimized for RAG/LLM
public Task<DocumentChunks> ExtractChunksAsync(
byte[] pdfBytes,
ChunkOptions options = null
);
// Extract metadata (page count, title, author)
public Task<PdfMetadata> ExtractMetadataAsync(byte[] pdfBytes);
}
ChunkOptions
public class ChunkOptions
{
public int MaxChunkSize { get; set; } = 512; // Max tokens per chunk
public int Overlap { get; set; } = 50; // Overlap between chunks
public bool PreserveSentenceBoundaries { get; set; } = true;
public bool IncludeMetadata { get; set; } = true;
}
DocumentChunk
public class DocumentChunk
{
public int Index { get; set; } // Chunk index in document
public int PageNumber { get; set; } // Source page number
public string Text { get; set; } // Chunk text content
public double Confidence { get; set; } // Extraction confidence (0.0-1.0)
public BoundingBox BoundingBox { get; set; } // Optional spatial info
}
Requirements
- .NET 8.0+ (tested on .NET 8, 9)
- Native Runtime: Automatically included in NuGet package
Note: .NET 6 support was dropped in v0.2.0 as it reached end-of-support in November 2024. Use v0.1.0 if you still require .NET 6 compatibility.
Building from Source
# Clone repository
git clone https://github.com/bzsanti/oxidize-pdf-dotnet.git
cd oxidize-pdf-dotnet
# Build native library
cd native
cargo build --release
# Build .NET wrapper
cd ../dotnet
dotnet build
# Run tests
dotnet test
Examples
See examples/ directory:
- BasicUsage/ - Simple text extraction
- KernelMemory/ - Full SharePoint crawler with RAG pipeline
License
This project is licensed under the MIT License - see LICENSE file.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
Acknowledgments
Built on top of oxidize-pdf by Santiago FernΓ‘ndez MuΓ±oz.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OxidizePdf.NET:
| Package | Downloads |
|---|---|
|
OxidizePdf.NET.KernelMemory
Kernel Memory content decoder backed by oxidize-pdf: structure-aware, page-cited PDF chunks dropped into your KM RAG pipeline in one call. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 0.18.0 | 0 | 9/27/2026 | |
| 0.17.0 | 126 | 8/22/2026 | |
| 0.16.1 | 159 | 6/29/2026 | |
| 0.16.0 | 135 | 6/27/2026 | |
| 0.15.0 | 143 | 6/26/2026 | |
| 0.14.0 | 128 | 6/12/2026 | |
| 0.13.0 | 127 | 6/12/2026 | |
| 0.12.0 | 138 | 6/6/2026 | |
| 0.11.0 | 140 | 6/5/2026 | |
| 0.10.0 | 155 | 5/28/2026 | |
| 0.9.0 | 224 | 5/10/2026 | |
| 0.8.0 | 226 | 5/6/2026 | |
| 0.7.1 | 239 | 4/20/2026 | |
| 0.7.0 | 236 | 4/13/2026 | |
| 0.6.0 | 240 | 3/21/2026 | |
| 0.5.0 | 253 | 3/18/2026 | |
| 0.4.0 | 279 | 3/15/2026 | |
| 0.3.1 | 244 | 3/9/2026 | |
| 0.3.0 | 235 | 3/6/2026 | |
| 0.2.2 | 592 | 12/10/2025 |