MIT Free for personal and commercial use. No licensing fees for private or commercial .NET apps. License

The Free C# PDF Library for .NET Developers

Generate professional PDFs entirely from C# — invoices, reports, contracts, and certificates — with a fluent, code-first API. Zero dependencies, no native binaries, MIT-licensed, with tables, images, bookmarks, vector graphics, barcodes, QR codes, custom embedded fonts, and AES-256 encrypted output built in.

Built for generating invoices, reports, business documents, and more — straight from your application, with no design tool in the loop.

⚖️ MIT Licensed
⚡ Zero Dependencies
.NET 8 / 9 / 10
v2.0.0 Custom Fonts & Devanagari

From C# code to a finished PDF

Describe the document with a fluent API — TerraPDF lays it out, paginates it, and writes the file. Write the code on the left; the page on the right is the actual PDF it produces, rendered by TerraPDF v2.0.0 — scannable QR code and barcode included.

PackingSlip.cs Full sample →
var brand = "#1A3C5E";
(string Item, string Sku, int Qty)[] lines =
[
    ("Wireless Mouse — Graphite",   "SKU-10231", 24),
    ("Mechanical Keyboard, 87-key", "SKU-10456", 12),
    ("USB-C Dock, Dual 4K",         "SKU-10877",  6),
    ("Laptop Stand, Aluminium",     "SKU-10920", 18),
];

Document.Create(doc =>
{
    doc.Page(page =>
    {
        page.Size(PageSize.A5);
        page.Margin(1.5, Unit.Centimetre);
        page.DefaultTextStyle(s => s.FontSize(10));

        page.Header().Column(col =>
        {
            col.Item().Row(row =>
            {
                row.RelativeItem().AlignMiddle()
                   .Text("TerraPDF Logistics").Bold().FontSize(13).FontColor(brand);
                row.AutoItem().AlignRight()
                   .Text("PACKING SLIP").Bold().FontSize(20).FontColor(brand);
            });
            col.Item().LineHorizontal(2, brand);
        });

        page.Content().PaddingTop(14).Column(col =>
        {
            col.Spacing(14);

            col.Item().Row(row =>
            {
                row.RelativeItem().Column(shipTo => { /* address block */ });
                row.AutoItem()   // vector QR code — new in v1.5
                   .QrCode("https://terrapdf.example/track/ORD-2026-1187", size: 88);
            });

            col.Item().Table(table =>
            {
                table.ColumnsDefinition(c =>
                {
                    c.RelativeColumn(5);  // Item
                    c.RelativeColumn(2);  // SKU
                    c.RelativeColumn(1);  // Qty
                });
                // brand header row + one shaded row per line item
            });

            col.Item().AlignCenter()  // vector Code128 — crisp at any zoom
               .Barcode("ORD-2026-1187", height: 46, showCaption: true);
        });

        page.Footer().AlignCenter().Text(t =>
        {
            t.Span("Page ");
            t.CurrentPageNumber();
            t.Span(" of ");
            t.TotalPages();
        });
    });
})
.PublishPdf("packing-slip.pdf");
The packing slip PDF generated by the code sample: a TerraPDF Logistics header, ship-to address with a QR tracking code, a shaded line-items table, and a Code128 barcode of the order number

What's new in TerraPDF v2.0.0

Custom font embedding with full Unicode support, including automatic, pure-C# Devanagari-aware shaping — no native dependency, none planned.

🔤

Custom Font Embedding

FontFamily.Register("Brand", "Brand-Regular.ttf") embeds any TrueType font as a Type0/CIDFontType2 composite font — brand typefaces, Cyrillic, Greek, and beyond WinAnsiEncoding.

Devanagari-Aware Rendering

Automatic matra reordering, conjunct ligatures (स्व, क्ष, ज्ञ), reph (धर्म, वर्तमान), and below/post-base 'ra' forms (क्र, त्र, प्र) — read straight from the font's own GSUB table.

📦

Embedded Once

Each registered font variant is embedded once per document, no matter how many pages or how many times it's used — with graceful fallback to the closest registered style.

✂️

Character-Boundary Wrap

A single word or token wider than the line now breaks at character boundaries instead of overflowing the container — plus Code128/QR codes and .NET 8/9/10 support from the v1.5 line.

How TerraPDF Compares

Choose TerraPDF when you want an open-source .NET PDF library with code-first PDF generation, a small dependency footprint, and permissive licensing.

Library Best fit Licensing model Dependency footprint TerraPDF advantage
TerraPDF Code-first document generation for .NET apps MIT Pure C#, zero runtime dependencies Simple fluent API, tables, links, bookmarks, vector graphics, barcodes/QR codes, and AES-256 encryption in one package
QuestPDF Polished report and document layouts Community and commercial tiers Includes native rendering assets TerraPDF keeps the install smaller and the license story simpler for any project size
PDFsharp Lower-level PDF drawing, editing, merging, and splitting MIT .NET library with platform-specific build options TerraPDF focuses on higher-level document layout with tables, TOC, and fluent composition
iText 7 Enterprise PDF workflows, standards, editing, and add-ons AGPL or commercial Full-featured commercial-grade toolkit TerraPDF is lighter for straightforward generation when you do not need enterprise PDF tooling
DinkToPdf HTML-to-PDF conversion through wkhtmltopdf MIT Requires native wkhtmltopdf binaries TerraPDF avoids native renderer deployment and builds PDFs directly from C#

Everything You Need to Build Amazing PDFs

A focused PDF toolkit for C# apps: layout, styling, navigation, media, graphics, and security without a heavy runtime footprint.

Zero Dependencies

Pure C# implementation with no native binaries, no third-party runtime packages, and no licensing restrictions. Just add the NuGet package and you're ready.

Fluent API

Intuitive, composable builder pattern that makes PDF generation feel natural. Chain methods together to create complex layouts with minimal code.

Full Layout Control

Columns, rows, tables, margins, padding, borders, backgrounds, and alignment. Everything you need for professional document layouts.

Typography

✍️ Rich Text Styling Bold, italic, underline, strikethrough with full font control
📏 Size & Scale Precise font sizing and line-height control
🎨 Color & Formatting Per-span formatting with custom colors and styles
🔤 Custom Fonts Embed TrueType fonts for full Unicode, with Devanagari-aware shaping

Layout

📐 Columns & Tables Flexible column, row, and table layouts
📐 Margins & Padding Full unit support: pt, mm, cm, inch
🖼️ Images Embed PNG and JPEG images directly into your PDFs with proper sizing and positioning support

Advanced

📑 Auto Table of Contents Generate a table of contents automatically from your headings (H1-H6) with clickable internal links and proper page numbering
🔗 Links & Bookmarks URI hyperlinks, internal document links, PDF bookmarks, and hierarchical outline navigation
📄 Headers & Footers Reusable headers, footers, and page numbers
🔐 PDF Encryption AES-256 PDF encryption by default with user passwords, owner passwords, and fine-grained permission flags
📈 Vector Canvas Shapes, paths, grids, charts, and diagrams
Barcodes & QR Codes Vector-rendered Code128 barcodes and ISO/IEC 18004 QR codes
À WinAnsi Text Windows-1252 and Latin-1 character coverage

Styling

🟢 Backgrounds & Borders Full, rounded, per-edge borders with fills
📐 Alignment Horizontal and vertical alignment controls
🏗️ Components Reusable components and conditional rendering

Build your next PDF with TerraPDF

Create reports, invoices, tables, images, bookmarks, and encrypted PDF documents in modern .NET apps with a small, MIT-licensed package.