---
title: "onepdf"
url: https://recursiveai.org/onepdf/
description: "A pure C# PDF library for .NET, with no dependency beyond .NET itself. Open and repair real-world PDFs, extract text in reading order, edit, fill forms, redact, sign, write PDF/A and PDF/UA, and lay out new documents. MIT or Apache-2.0."
---

# onepdf

A PDF library for .NET, written in C# with no dependency beyond .NET itself. It opens the files that are actually out there, reads their text in order, edits and signs them, and lays out new ones.

```sh
dotnet add package RecursiveAI.OnePdf
```

- [Getting started](https://recursiveai.org/onepdf/docs/getting-started/)
- [Docs](https://recursiveai.org/onepdf/docs/)
- [Cookbook](https://recursiveai.org/onepdf/cookbook/)
- [Articles](https://recursiveai.org/onepdf/articles/)
- [GitHub](https://github.com/recursive-ai-oss/onepdf-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf)

## A quick look

Text comes out as glyphs, words, lines and blocks with positions, in reading order: the structure tree for tagged files, geometry otherwise, right-to-left text included.

[How reading order works](https://recursiveai.org/onepdf/docs/text-layout/)

*Program.cs · C#*

```
using OnePdf;
using OnePdf.Text;
 
using PdfDocument doc = PdfDocument.Open("in.pdf");
 
// Every page, in reading order, in parallel.
var pages = doc.ExtractText();
Console.WriteLine(pages[0].Text);
 
// Words with positions, on one page.
foreach (PdfTextWord w in doc.Pages[0].ExtractText().Words)
    Console.WriteLine($"{w.Text} {w.Bounds}");
```

### Opens real-world files

Cross-reference streams, object streams, incremental files and a documented repair chain for damaged ones, with every repair recorded. Encrypted files from RC4 to AES‑256.

### Edits and saves

Delete, reorder, rotate, merge and split pages. Fill and flatten forms, redact areas, draw text and images, and save a clean file or an incremental update.

### Signs and verifies

Checks signatures, time-stamps and certificate chains, and shows what changed after each signature. Signs as PAdES B-B or B-T, visible or invisible.

### PDF/A and PDF/UA

Writes PDF/A-2 and PDF/A-3, and PDF/UA-1 and PDF/UA-2 from documents it laid out or tagged. A save that can’t conform is refused, with every violation listed.

### Lays out new documents

`RecursiveAI.OnePdf.Layout` builds documents from code: shaped text, tables, lists, images, SVG and page X of Y, streamed as a tagged PDF.

### Safe on files you didn’t write

No `unsafe` code. Limits are checked before the work they guard, and the parsers, filters and font readers are fuzzed. It never runs a document’s scripts or touches the network.

## Faster than PdfPig on every task we measured

Against PdfPig 0.1.16 on the same files, with BenchmarkDotNet. Speedups range from 1.10× to 8.50×.

[Every result and the method](https://github.com/recursive-ai-oss/onepdf-csharp/blob/v1.11.0/README.md#benchmarks)

- **Reading**: Open, metadata, full text and words with positions: faster on every row, from 1.10× (metadata of a small file) to 8.50× (metadata of a 300-page article).
- **Text quality**: Character error on content of 0.3% on a generated set of 62 files, against 5.6% for PdfPig’s layout pipeline; 5.6% against 13.5% on 92 real-world files.
- **Layout**: Against MigraDoc 6.2.4 on an invoice, a 50-page report, a 10,000-row table, a 500-page book and 32 concurrent invoices: faster on all five.
- **Robustness**: Over GovDocs1, a SafeDocs sample and the veraPDF corpus, opening each file, extracting its text and interpreting every page found 0 crashes and 0 hangs.

## The packages

- **Packages**: `RecursiveAI.OnePdf`, with `.Layout` for generating documents, `.Fonts` for substitutes of the standard 14 fonts and `.Hyphenation` for 26 language variants. Version 1.11.0.
- **Pages**: `page.Interpret(device)` hands a 2D engine paths, glyph runs, images and shadings, and `PdfDisplayList` records and replays them. onepdf doesn’t rasterize pages or do OCR.
- **Migration**: Guides for moving from PdfPig, PDFsharp and QuestPDF.
- **.NET**: .NET 10. NativeAOT and trimming are supported. Output is the same on every platform.
- **License**: MIT or Apache-2.0. The Fonts and Hyphenation packages also carry the licenses of the fonts and patterns they ship.
- **How it was made**: AI agents designed, wrote and benchmarked it on [Alera](https://recursiveai.org/alera/); Kurtis decided what to build. [Read the case study](https://recursiveai.org/research/building-onepdf-csharp/).

## Go further

- [GitHub](https://github.com/recursive-ai-oss/onepdf-csharp)
- [NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf)
- [All docs](https://recursiveai.org/onepdf/docs/)
- [Cookbook](https://recursiveai.org/onepdf/cookbook/)
- [Articles](https://recursiveai.org/onepdf/articles/)
- [Layout guide](https://recursiveai.org/onepdf/docs/layout/)
- [Page operations](https://recursiveai.org/onepdf/docs/page-operations/)
- [Forms](https://recursiveai.org/onepdf/docs/forms/)
- [Signatures](https://recursiveai.org/onepdf/docs/signatures/)
- [PDF/A](https://recursiveai.org/onepdf/docs/pdfa/)
- [PDF/UA](https://recursiveai.org/onepdf/docs/pdfua/)
- [Moving from PdfPig](https://recursiveai.org/onepdf/docs/migrating-from-pdfpig/)
- [Changelog](https://github.com/recursive-ai-oss/onepdf-csharp/blob/v1.11.0/CHANGELOG.md)
