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.
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 worksusing 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}");
What it does
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- 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.Layoutfor generating documents,.Fontsfor substitutes of the standard 14 fonts and.Hyphenationfor 26 language variants. Version 1.11.0. - Pages
page.Interpret(device)hands a 2D engine paths, glyph runs, images and shadings, andPdfDisplayListrecords 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; Kurtis decided what to build. Read the case study.