TerraPDF 1.4.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package TerraPDF --version 1.4.0
                    
NuGet\Install-Package TerraPDF -Version 1.4.0
                    
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="TerraPDF" Version="1.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TerraPDF" Version="1.4.0" />
                    
Directory.Packages.props
<PackageReference Include="TerraPDF" />
                    
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 TerraPDF --version 1.4.0
                    
#r "nuget: TerraPDF, 1.4.0"
                    
#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 TerraPDF@1.4.0
                    
#: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=TerraPDF&version=1.4.0
                    
Install as a Cake Addin
#tool nuget:?package=TerraPDF&version=1.4.0
                    
Install as a Cake Tool

TerraPDF

A free, pure C# library designed for fast and reliable PDF generation.

TerraPDF

NuGet License: MIT

πŸ“š To know more about it and documentation and sample codes. Please visit its website https://terrapdf.com/

New in 1.4.0: AES-256 encryption by default, plus bytes/stream image sources, anchor-based bookmarks, and the immutable TextStyle callback for multi-span text.

TerraPDF is a lightweight, zero-dependency, pure C# library for generating professional PDF 1.7 documents programmatically. It provides a fluent, composable API that covers the full document-authoring lifecycle β€” from page layout and rich text to tables, images, hyperlinks, and multi-page pagination β€” with no native binaries, no third-party runtime packages, and no licensing restrictions.

  • No native dependencies, no third-party packages
  • Targets .NET 8 and .NET 9
  • Text styling β€” bold, italic, bold-italic, strikethrough, underline, font size, colour
  • Three built-in font families β€” Helvetica, Times, Courier β€” via FontFamily(), no embedding needed
  • Configurable line-height multiplier per text block
  • Per-span formatting inside mixed-style text blocks
  • Margin and padding decorators with full unit support
  • Background fills and borders (full, rounded, and per-edge)
  • Rounded-corner borders and filled rounded boxes
  • Per-edge borders β€” BorderTop, BorderBottom, BorderLeft, BorderRight
  • Horizontal and vertical alignment
  • Column, Row, and Table layouts
  • PNG and JPEG image embedding
  • Horizontal and vertical rule lines
  • Explicit page breaks via PageBreak()
  • Clickable hyperlink (URI) annotations via Hyperlink()
  • Internal document links (GoTo) via InternalLink()
  • Automatic Table of Contents generation from H1–H6 headings
  • PDF bookmarks / outlines with hierarchical nesting
  • Document metadata (Title, Author, Subject, Keywords, Creator)
  • Conditional rendering via ShowIf
  • Reusable components via IComponent
  • Headers, footers, and page numbers
  • AES-256 PDF encryption by default β€” user password, owner password, and fine-grained permission flags (PdfPermissions) via container.Encrypt(); AES-128 remains available for compatibility
  • Images from bytes and streams β€” Image(byte[]) / Image(Stream) with transparency and deduplication
  • Anchor-based bookmarks β€” bookmark content directly to rendered elements and keep destinations accurate
  • Full WinAnsiEncoding character coverage
  • Vector graphics canvas β€” lines, rectangles, rounded rectangles, circles, ellipses, arbitrary BΓ©zier paths, polygons, and grid helpers via container.Canvas()
  • Fluent, composable API

Installation

dotnet add package TerraPDF

Quick Start

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");

Full Documentation

For complete API reference and detailed guides, visit the docs directory:

  • Getting Started β€” Installation, Quick Start, and basic usage
  • Text & Spans β€” Single-span and multi-span text, styling, page numbers
  • Layout β€” Column, Row, and Table layouts with alignment and spacing
  • Row and Column Layout β€” Detailed Row and Column layout examples
  • Decorators β€” Padding, margin, backgrounds, borders, and styling
  • Images β€” PNG and JPEG embedding with sizing and alignment
  • Page Sizes & Units β€” Built-in page sizes and unit conversions
  • Colors β€” Material Design color palette with shades
  • Encryption & Security β€” AES-256 by default, with AES-128 compatibility mode and permission flags
  • Vector Graphics β€” Canvas API, shapes, paths, grids, and charts
  • Table of Contents β€” Automatic TOC generation from headings
  • Bookmarks β€” PDF bookmarks and outlines
  • Components & Templates β€” Reusable components and document templates
  • Metadata β€” Document metadata (Title, Author, Subject, Keywords, Creator)
  • Unicode & Character Encoding β€” WinAnsiEncoding and character coverage
  • Samples β€” Complete working examples demonstrating all features

Building from Source

git clone https://github.com/sahebansari/TerraPDF.git
cd TerraPDF
dotnet build
dotnet test

Requires .NET 8 SDK or later.


Contributing

Contributions are welcome! Please read CONTRIBUTING.md for coding standards, project structure, how to run tests, and the pull-request process.


Changelog

All notable changes are documented in CHANGELOG.md, following the Keep a Changelog format.


Security

To report a vulnerability, please follow the responsible-disclosure process described in SECURITY.md. Do not open a public issue for security problems.


License

MIT β€” see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on TerraPDF:

Package Downloads
PdfSharpDslCore

A DSL using TerraPDF to generate PDF

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.2.0 43 9/20/2026
2.1.0 141 9/2/2026
2.0.1 126 8/28/2026
2.0.0 1,383 7/23/2026
1.5.1 258 7/10/2026
1.5.0 146 7/9/2026
1.4.0 436 7/5/2026
1.3.0 450 5/22/2026
1.2.3 117 5/18/2026
1.2.2 124 5/3/2026
1.2.1 127 5/2/2026
1.2.0 129 4/30/2026