TerraPDF Logo

A lightweight, zero-dependency, pure C# library for generating professional PDFs. Layout, tables, images, links, bookmarks, vector graphics, WinAnsi text, and AES-128 encryption with no native binaries.

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

New in TerraPDF 1.3.0

Password-protect documents, restrict actions with permission flags, and build richer graphics-heavy PDFs.

🔐

AES-128 PDF Encryption

Protect documents with user and owner passwords, encrypt content streams and image XObjects, and control print, copy, edit, form, accessibility, and assembly permissions.

📈

Vector Graphics Canvas

Draw lines, rectangles, rounded rectangles, circles, ellipses, paths, polygons, grids, charts, and diagrams directly inside TerraPDF layout containers.

À

WinAnsi Character Coverage

Render Windows-1252 typographic specials and Latin-1 characters with extended AFM width tables for accurate wrapping and measurement.

Encryption Reliability Fixes

Encrypted PDFs now write a stable trailer ID, avoid invalid crypt filters, use correct AES padding, and include broader tests for password and permission combinations.

Why TerraPDF?

Professional PDF generation made simple. Designed for developers who value simplicity, performance, 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

Generate your first PDF in under a minute with TerraPDF's simple 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 complete toolkit for professional PDF generation in C#. No compromises, no hidden costs.

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

Ready to Get Started?

Generate PDFs in minutes with TerraPDF's simple, zero-dependency API.