v1.1.0 · Free Community license · .NET 8

PDF generation for .NET, built from the spec up

SoftZenPdf implements ISO 32000 directly. Create, read, merge, encrypt, fill and archive PDFs with one managed library and no third-party dependencies.

dotnet add package SoftZenPdf

Available on NuGet.

Program.cs
using SoftZenPdf;

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

page.Content
    .DrawText("Hello, SoftZenPdf", 72, 770, StandardFont.Helvetica, 24)
    .DrawRectangle(72, 560, 200, 120, fill: PdfColor.FromHex("#3B82F6"))
    .DrawCircle(420, 620, 60, stroke: PdfColor.Red, lineWidth: 3);

document.Save("hello.pdf");
hello.pdf
Hello, SoftZenPdf (72, 770) (72, 560) (420, 620)
Purple markers show PDF coordinates: points (1/72 inch) measured from the bottom-left corner of the page.
Features

From the first page to the archival copy

One package covers creating documents, reading and recombining existing ones, protecting them and keeping them for the long term.

API tour

Short, readable code for real PDF work

Every example below is cut from a project that compiles against the library in the same solution, so it cannot drift from the API.

Program.cs
using SoftZenPdf;

var document = new PdfDocument();
var page = document.AddPage();
var noto = TrueTypeFont.FromFile("NotoSans-Regular.ttf");

page.Content
    .DrawText("Héllo wörld — Ωμέγα — Привет — €5", 72, 770, noto, 18)
    .DrawImage(PdfImage.FromFile("color-chart.jpg"), 72, 540, 240, 160)
    .DrawImage(PdfImage.FromFile("logo.png"), 340, 540, 160);

document.Save("fonts-and-images.pdf");

The TrueType font is subset to the glyphs you use; JPEG data is embedded as-is. Read the guide →

Program.cs
using SoftZenPdf;

var report = PdfReader.Open("report.pdf");
var appendix = PdfReader.Open("appendix.pdf");

var combined = PdfDocument.Merge(report, appendix);
combined.Pages[^1].Rotation = 90;
combined.MovePage(combined.Pages.Count - 1, 0);
combined.Save("combined.pdf");

PdfDocument.Extract(report, [2, 0]).Save("pages-3-and-1.pdf");

Pages keep their content, resources, size and rotation when they move between documents. Read the guide →

Program.cs
using SoftZenPdf;

var document = new PdfDocument();
document.AddPage().Content.DrawText("Confidential", 72, 770, StandardFont.HelveticaBold, 24);

document.Encrypt(userPassword: "user123", ownerPassword: "owner456",
    permissions: PdfPermissions.All & ~PdfPermissions.CopyContent);
document.Save("secret.pdf");

var reader = PdfReader.Open("secret.pdf", "user123");
Console.WriteLine(reader.EncryptionAlgorithm); // Aes256

AES-256 is the default. Permissions are advisory: viewers enforce them, but the user password decrypts. Read the guide →

Program.cs
using SoftZenPdf;

var document = new PdfDocument();
var page = document.AddPage();
page.AddTextField("Name", 200, 690, 260, 22);
page.AddCheckBox("Subscribe", 200, 652, 16);
document.Save("form.pdf");

var filler = PdfFormFiller.Open("form.pdf");
filler.SetValue("Name", "Jane Doe");
filler.SetChecked("Subscribe", true);
filler.Save("form-filled.pdf");

Filling appends an incremental update, so the original bytes of the form stay untouched. Read the guide →

Program.cs
using SoftZenPdf;

var reader = PdfReader.Open("hello.pdf");
Console.WriteLine(reader.ExtractText(0));

foreach (var run in reader.ExtractTextWithPositions(0))
    Console.WriteLine($"{run.Text} at ({run.X1:0}, {run.Y1:0}), {run.FontSize}pt {run.FontName}");

Text comes out in content-stream order by default; TextOrder.Visual groups it into lines. Read the guide →

Program.cs
using SoftZenPdf;

var document = PdfDocument.CreateForPdfA();
document.Info.Title = "Annual report";
var font = TrueTypeFont.FromFile("NotoSans-Regular.ttf");

document.AddPage().Content.DrawText("Archived", 72, 770, font, 14);
document.Save("report-pdfa.pdf"); // throws PdfAException if a check fails

Saving validates the document first and lists every violation it finds. Read the guide →

Why SoftZenPdf

Nothing hidden under the hood

SoftZenPdf is a from-scratch implementation, not a wrapper around another engine. Every byte it writes comes from code you can read in the repository.

See the known limitations
  • No external dependencies

    The package references nothing but the .NET base class library. No native binaries, no wrapped PDF engine, nothing extra to deploy.

  • Built from ISO 32000

    The object model, cross-reference tables, content streams, font embedding and the standard security handler are implemented directly from the specification.

  • Pure managed .NET 8

    No platform-specific APIs and no native code, so nothing ties the library to one operating system.

  • Checked against independent tools

    Decryption is tested on files encrypted by qpdf, and TrueType metrics against values captured from DirectWrite. A veraPDF cross-check of the PDF/A output is pending.

  • Upfront about its limits

    The documentation lists what is not supported yet, from CFF fonts and complex-script shaping to digital signatures.

Get started

Ready to write your first PDF?

Install the package, run the hello-world example and open hello.pdf in any viewer.