TerraPDF Logo

Pure C# PDF Generation for .NET

A lightweight, zero-dependency C# PDF library and .NET PDF generator for creating professional documents from code. Build reports, invoices, tables, images, links, bookmarks, metadata, vector graphics, WinAnsi text, and AES-128 encrypted PDFs with no native binaries.

NuGet Version .NET 8 & 9
NuGet Downloads MIT License
GitHub Stars Zero Dependencies
v1.3.0 AES-128 Encryption

What's new in TerraPDF v1.3.0

Secure PDFs with AES-128 encryption, fine-grained permissions, and built-in vector graphics support.

🔐

AES-128 Encryption

Protect documents with user/owner passwords, encrypt content streams and images, and enforce print, copy, edit, form, accessibility, and assembly rules.

📈

Vector Graphics Canvas

Create lines, shapes, paths, charts, and diagrams directly inside TerraPDF layouts without external libraries.

À

WinAnsi Text Support

Render Windows-1252 and Latin-1 characters with accurate widths and wrapping for better typography.

Encryption Stability

Fixed trailer IDs, invalid crypt filters, AES padding, and expanded password/permission test coverage for reliable encrypted output.

Why TerraPDF?

Professional PDF generation in C# made simple. Designed for .NET developers who need code-first document creation, predictable layout, and full control.

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.

🖼️

Image Support

Embed PNG and JPEG images directly into your PDFs with proper sizing and positioning support.

📑

Automatic TOC

Generate a table of contents automatically from your headings (H1-H6) with clickable internal links and proper page numbering.

🔗

Hyperlinks & Bookmarks

Support for URI hyperlinks, internal document links, PDF bookmarks, and hierarchical outline navigation.

🔐

Document Security

AES-128 PDF encryption with user passwords, owner passwords, and fine-grained permission flags.

Quick Start

Create your first PDF in C# in under a minute with TerraPDF's simple fluent API.

dotnet add package TerraPDF

Or browse the NuGet package page for all versions.

Hello World Example

using TerraPDF.Core;
using TerraPDF.Helpers;

Document.Create(container =>
{
    container.Page(page =>
    {
        page.Size(PageSize.A4);
        page.Margin(2, Unit.Centimetre);
        page.PageColor(Color.White);
        page.DefaultTextStyle(s => s.FontSize(11));

        page.Header()
            .Text("My Report")
            .Bold()
            .FontSize(24)
            .FontColor(Color.Blue.Darken2);

        page.Content()
            .Column(col =>
            {
                col.Spacing(8);
                col.Item().Text("Hello, TerraPDF!");
                col.Item().Text("This paragraph is italic.").Italic();
                col.Item()
                   .Margin(6).Background(Color.Grey.Lighten4).Padding(10)
                   .Text("Indented callout box").Bold();
            });

        page.Footer()
            .AlignCenter()
            .Text(t =>
            {
                t.Span("Page ");
                t.CurrentPageNumber().FontSize(9);
                t.Span(" / ");
                t.TotalPages().FontSize(9);
            });
    });
})
.PublishPdf("output.pdf");
Note: TerraPDF targets .NET 8 and .NET 9. Works with ASP.NET Core, console apps, Windows services, and any .NET application.

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.

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

Layout

📐 Columns & Tables Flexible column, row, and table layouts
📐 Margins & Padding Full unit support: pt, mm, cm, inch
🖼️ Images PNG and JPEG embedding with positioning

Advanced

📑 Auto Table of Contents TOC generated from H1–H6 with clickable links
🔗 Links & Bookmarks URI hyperlinks, internal links, and bookmarks
📄 Headers & Footers Reusable headers, footers, and page numbers
🔐 PDF Encryption AES-128 protection with passwords and permissions
📈 Vector Canvas Shapes, paths, grids, charts, and diagrams
À 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

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, and AES-128 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#
Pure C# PDF generation

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.

dotnet add package TerraPDF