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.
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");
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.
-
Learn more
PDF generation and vector graphics
Pages in any standard or custom size; text, lines, rectangles, ellipses and Bézier paths in RGB, with opacity and Flate-compressed content streams.
-
Learn more
Standard and TrueType fonts
The 14 standard fonts with Adobe metrics, plus TrueType embedding with automatic subsetting and ToUnicode maps, so copied text stays readable.
-
Learn more
Images and scans
JPEG, PNG, GIF, BMP and TIFF, including multi-page and fax TIFFs, decoded by SoftZenPdf itself. Turn images and scans into PDF pages in one call, and make them searchable with the OCR add-on.
-
Learn more
HTML to PDF and flowing layout
Convert HTML and CSS templates with SoftZenPdf's own layout engine, or lay out paragraphs, lists and tables that flow across pages yourself.
-
Learn more
Bookmarks, links, metadata, watermarks
Nested bookmarks, internal and web links, document info mirrored in XMP metadata, and text or image watermarks on every page.
-
Learn more
Merge, split, reorder, rotate
Read existing PDFs (classic and stream cross-reference tables, object streams, basic repair) and recombine their pages into new documents.
-
Learn more
Encryption and permissions
AES-256 by default, with AES-128 and RC4 for older viewers. Set user and owner passwords and permissions, and open protected files.
-
Learn more
Interactive forms
Text fields, check boxes, radio groups, dropdowns, list boxes, push buttons and signature placeholders with real appearance streams. Fill existing forms in place.
-
Learn more
Text extraction
Plain text or positioned runs from any page the reader can open, decoded through ToUnicode maps, standard encodings and the Adobe Glyph List.
-
Learn more
PDF/A-2b archiving
A creation mode that requires embedded fonts, adds an sRGB output intent and XMP identification, and checks the file before saving it.
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.
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 →
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 →
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 →
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 →
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 →
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 →
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.
Ready to write your first PDF?
Install the package, run the hello-world example and open hello.pdf in any viewer.