CodexPdf.Core 1.0.2

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

CodexPdf.Core

An independent, modern .NET library for creating, reading, and editing PDF documents — pages, text, tables, forms, annotations, digital signatures, encryption, and HTML/DOCX conversion — built on public PDF specifications with no dependency on proprietary PDF SDKs.

CI License: MIT .NET 10 Status: Pre-release

Overview

CodexPdf is a from-scratch PDF library for .NET, shipped as a single package (CodexPdf.Core) with no separate installs to track for different features.

It covers document creation, classic PDF reading (plus cross-reference streams and object streams, PDF 1.5+), text extraction and search, drawing (shapes/text/images), tables, bookmarks, hyperlinks, annotations, AcroForm fields, page manipulation, merge/split, RC4/AES-128/AES-256 encryption, PKCS#7/CMS digital signatures, TrueType/OpenType font embedding, raster rendering to bitmaps (including rendering pages from arbitrary third-party PDFs, not just ones this library wrote), PDF/A conformance checking, structural validation, optimization, HTML/DOCX/image/text conversion, Windows printing, ASP.NET Core integration, and a public low-level API for inspecting raw PDF objects.

The project is under active development (pre-1.0) - see Versioning and Changelog for what's stable versus still moving.

Features

  • Creation: pages (A0-A5, Letter, Legal, Executive, or custom size), portrait/landscape, margins, background color, metadata, document language, viewer preferences.
  • Text: draw text at coordinates or word-wrapped into a rectangle, left/center/right/justify alignment, rich (multi-run) text, TrueType/OpenType font embedding with automatic subsetting, font fallback, Unicode (including CJK via CID/Identity-H fonts).
  • Drawing: lines, rectangles, rounded rectangles, circles, ellipses, polygons, polylines, arcs, Bézier curves - stroke/fill color, line width, dash patterns, transparency, rotation, clipping.
  • Images: PNG, JPEG, GIF, BMP, TIFF, WebP - load, resize, crop, rotate, compress, position with aspect-ratio preservation.
  • Tables: column/row spanning, per-side borders, background/padding/alignment, nested tables, automatic column sizing, repeating header rows across page breaks.
  • Headers/footers: page number, total pages, date/time, document title, images, tables, different first-page/odd/even headers.
  • Reading: pages, metadata, text, images, annotations, bookmarks, links, form fields, attachments; a public low-level API for arbitrary PDF object traversal.
  • Editing: add text/images/shapes/watermarks/annotations to an existing PDF; remove/insert/reorder/rotate/crop pages; update metadata.
  • Merge & split: combine documents or files; split by page range, page count, or bookmark.
  • Forms: text fields, checkboxes, radio buttons, combo/list boxes, push buttons, signature field placeholders - read, set, clear, and flatten.
  • Security: user/owner passwords, RC4/AES-128/AES-256 encryption, printing/copying/editing/form-filling/annotation permission restrictions.
  • Digital signatures: PKCS#7/CMS signing with a real X.509 certificate, multiple signatures, signing an encrypted document, incremental signing, signature validation.
  • Conversion: HTML→PDF (real HTML5 parsing, CSS cascade and box model, lists, links), DOCX→PDF, images→PDF, text→PDF, PDF→HTML, PDF→text - plus a plugin architecture (IPdfConverter<TInput, TOutput>) for registering your own converters.
  • Rendering: rasterize any page - including one from an arbitrary third-party PDF, not just one this library wrote - to a bitmap (PNG/JPEG/TIFF) with configurable DPI, scaling, and anti-aliasing.
  • Printing: send a document to a Windows printer.
  • ASP.NET Core: IServiceCollection registration and minimal-API/MVC result helpers for serving generated PDFs.
  • PDF/A & accessibility: PDF/A-1/2/3 conformance validation, tagged PDF (logical reading order, alt text, heading/table structure).
  • Attachments, bookmarks, and hyperlinks: embedded files, nested bookmarks with styling (color/bold/italic), URL/internal/named-destination links.
  • Streaming: Save/Open overloads for file paths, byte[], and Stream, with decompression-bomb and oversized-input guards for untrusted PDF input.

Installation

dotnet add package CodexPdf.Core

One package covers everything - creation, reading/editing, digital signatures, HTML/DOCX/image/text conversion, Windows printing, and ASP.NET Core integration. See Dependencies for what it brings in.

Quick Start

using CodexPdf.Core;

using var document = new PdfDocument();
var page = document.AddPage(PdfPageSize.A4);
page.Canvas.DrawText("Hello PDF", new PdfTextStyle { FontSize = 24 }, new PdfPoint(50, 750));
document.Save("hello.pdf");

Usage

Reading and searching

using var document = PdfDocument.Open("input.pdf");
Console.WriteLine($"{document.PageCount} pages, title: {document.Title}");

var text = document.ExtractText();
var matches = document.Search("Invoice Number");

Tables

using var document = new PdfDocument();
var page = document.AddPage(PdfPageSize.A4);

var table = document.CreateTable();
table.AddColumn("Name");
table.AddColumn("Email");
table.AddColumn("Status");
table.AddRow("Ada Lovelace", "ada@example.com", "Active");

document.AddTable(table, page, new PdfRectangle(50, 100, 495, 600));
document.Save("report.pdf");

PDF Operations

Create

using var document = new PdfDocument();
var page = document.AddPage(PdfPageSize.A4);
page.Orientation = PdfPageOrientation.Portrait;
page.Canvas.DrawRectangle(new PdfRectangle(50, 700, 200, 80), strokeColor: "0,0,0", fillColor: "0.9,0.9,1");
document.Metadata.Title = "Sample Report";
document.Save("create.pdf");

Read

using var document = PdfDocument.Open("input.pdf");
foreach (var page in document.Pages)
{
    Console.WriteLine(page.ExtractText(page.CropBox ?? new PdfRectangle(0, 0, page.Width, page.Height)));
}

Edit

using var editable = PdfEditableDocument.Open("input.pdf");
var page = editable.GetPage(1);
page.Rotation = 90;
page.AppendContent.DrawText("DRAFT", new PdfTextStyle { FontSize = 48 }, new PdfPoint(150, 400));
editable.Save("edited.pdf");

Merge

using var merged = PdfDocument.MergeFiles("part1.pdf", "part2.pdf", "part3.pdf");
merged.Save("merged.pdf");

Split

// Byte-range/stream based - doesn't load the whole source document into the object model.
PdfDocument.Split("report.pdf", firstPage: 1, lastPage: 5, "first-five-pages.pdf");

Forms

using var document = new PdfDocument();
var page = document.AddPage(PdfPageSize.A4);
page.AddTextField("FullName", new PdfRectangle(50, 700, 250, 20));
document.Save("form.pdf");

using var reader = PdfReadDocument.Open("form.pdf");
reader.SetTextField("FullName", "Ada Lovelace", "form-filled.pdf");

Convert

using CodexPdf.Core.Conversion;

var document = HtmlToPdf.Convert("<h1>Invoice</h1><p>Thank you for your business.</p>");
document.Save("invoice.pdf");

Security

using var document = new PdfDocument();
document.AddPage(PdfPageSize.A4);

document.Security.UserPassword = "let-me-in";
document.Security.EncryptionAlgorithm = PdfEncryptionAlgorithm.Aes256;
document.Security.AllowPrinting = true;
document.Security.AllowCopying = false;

document.Save("secure.pdf");

Configuration

Register CodexPdf for dependency injection, with configurable defaults:

services.AddPdfProcessing(options =>
{
    options.DefaultPageSize = PdfPageSize.A4;
    options.EnableCompression = true;
});

Serve a generated PDF from a minimal API endpoint:

app.MapGet("/reports/{id}", (int id) =>
{
    using var document = new PdfDocument();
    document.AddPage(PdfPageSize.A4);
    return PdfResults.File(document, $"report-{id}.pdf");
});

Dependencies

CodexPdf.Core is a single package; everything below is included, not a separate install.

Package Used for
SkiaSharp Rasterizing pages to bitmaps, image decode/encode, font metrics
System.Security.Cryptography.Pkcs PKCS#7/CMS digital signature creation and verification
AngleSharp Real HTML5 parsing for HTML→PDF conversion
DocumentFormat.OpenXml Reading .docx documents for DOCX→PDF conversion
System.Drawing.Common Windows print spooler integration (document.Print(...))
ASP.NET Core shared framework services.AddPdfProcessing(...) DI registration, PdfResults minimal-API/MVC result helpers

Supported Frameworks

Targets .NET 10. Printing calls into System.Drawing.Common/GDI+ and is Windows-only at runtime (PdfPrinter.IsSupported reports this; calling Print elsewhere throws PlatformNotSupportedException). Every other feature is fully cross-platform.

API Reference

Generated from the XML doc comments via DocFX. Build and browse it locally:

dotnet tool install -g docfx   # once
docfx docs/docfx.json --serve  # builds and serves at http://localhost:8080

Examples

  • Tutorials - task-oriented walkthroughs: getting started, reading/searching, forms, security/signatures, conversion, rendering, ASP.NET Core integration. Every code example was compiled and run against the actual library before publishing.
  • Migration Guide - coming from another .NET PDF library? Start here.
  • samples/CodexPdf.Core.Sample - a runnable console sample.

Development

dotnet build CodexPdf.sln
dotnet test CodexPdf.sln
  • BENCHMARKS.md - measured throughput/allocation numbers (creation, reading, encryption, rendering, conversion) and instructions to reproduce them.
  • THREAD_SAFETY.md - which types are safe to share across threads and which aren't (short version: building a document is not thread-safe, reading one concurrently is).
  • SECURITY.md - the encryption implementation's design notes.

Contributing

Contributions are welcome. See CONTRIBUTING.md for the build/test workflow and expectations before opening a pull request. Please don't copy proprietary PDF-library implementations or fixtures - CodexPdf is built independently from public PDF specifications.

Versioning

CodexPdf follows Semantic Versioning. Currently ships as 0.1.0 (pre-1.0): public APIs may still change between minor versions until 1.0.0. Breaking changes are called out explicitly in the Changelog.

Changelog

See CHANGELOG.md for release notes, including breaking changes.

License

MIT - see LICENSE. Third-party dependencies (SkiaSharp, AngleSharp, DocumentFormat.OpenXml, System.Security.Cryptography.Pkcs, System.Drawing.Common) are documented in Dependencies and are all permissively licensed.

Author

Lay Ly

Contact

Support

  • Issues - bug reports and feature requests.
  • Discussions - questions and general discussion.
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
1.0.2 34 9/15/2026
1.0.1 40 9/15/2026
1.0.0 38 9/15/2026