.NET developers have more PDF library options than ever—but quality varies enormously. Some packages handle generation well but stumble on viewing; others are read-only; a few require AGPL compliance for commercial use. This article compares the leading .NET and C# PDF SDKs on API design, NuGet availability, feature completeness, and real-world integration complexity.
Top .NET PDF SDKs: Comparison Table
ComPDF for .NET: Deep Dive
ComPDF's .NET SDK is distributed via NuGet and covers the full PDF workflow in a Windows desktop or server environment.
Installation
# Core SDK
dotnet add package ComPDFKit.NetFramework
# Conversion add-on
dotnet add package ComPDFKit_Conversion.NetFramework
Initialization
using ComPDFKit.NativeMethod;
using ComPDFKit.PDFDocument;
// Load native runtime
CPDFSDKVerifier.LoadNativeLibrary();
// Verify license
LicenseErrorCode result = CPDFSDKVerifier.LicenseVerify("license.xml");
if (result != LicenseErrorCode.E_LICENSE_SUCCESS)
{
Console.WriteLine($"License error: {result}");
return;
}
Opening a Document and Accessing Pages
CPDFDocument doc = CPDFDocument.InitWithFilePath("sample.pdf");
Console.WriteLine($"Page count: {doc.PageCount}");
CPDFPage page = doc.PageAtIndex(0);
Console.WriteLine($"Page size: {page.PageSize}");
PDF to Word Conversion with AI Layout
using ComPDFKit.Conversion;
WordOptions options = new WordOptions
{
EnableAiLayout = true,
EnableOCR = false,
ContainImage = true,
ContainAnnotation = true
};
bool success = CPDFConversion.StartPDFToWord(
inputPath: "input.pdf",
password: "",
outputFolderPath: "output/",
options: options
);
Source: Official ComPDF Windows Conversion SDK — github.com/ComPDFKit/compdfkit-conversion-sdk-windows
Adding an Annotation
CPDFPage page = doc.PageAtIndex(0);
CPDFHighlightAnnotation highlight = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT)
as CPDFHighlightAnnotation;
highlight.SetRect(new CRect(72, 72, 200, 88));
highlight.SetColor(new byte[] { 255, 255, 0 }, 128);
highlight.UpdateAp();
doc.WriteToFilePath("annotated.pdf");
iText 7 for .NET
iText is a leading option for programmatic PDF generation in .NET, especially for invoices, reports, and compliance-heavy outputs.
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using PdfWriter writer = new PdfWriter("output.pdf");
using PdfDocument pdf = new PdfDocument(writer);
using Document document = new Document(pdf);
document.Add(new Paragraph("Hello, iText 7!"));
License note: AGPL for open-source distribution. Closed-source commercial apps require a paid license from iText Group.
PdfPig (Apache 2.0)
PdfPig is lightweight and strong for text extraction and parsing pipelines in .NET workloads.
using UglyToad.PdfPig;
using PdfDocument document = PdfDocument.Open("sample.pdf");
foreach (var page in document.GetPages())
{
foreach (var word in page.GetWords())
{
Console.WriteLine(word.Text);
}
}
Capabilities:
- ✅ Text extraction (with position data)
- ✅ Image extraction
- ✅ Basic PDF creation
- ❌ Cannot edit existing PDFs
- ❌ No form-filling, digital signatures, or annotation editing
License: Apache 2.0 — github.com/UglyToad/PdfPig
PdfPig is ideal for data extraction pipelines. It is not a replacement for a full SDK in production document workflows that require editing or signing.
PDFsharp is MIT-licensed and suitable for basic PDF creation/modification workflows. MigraDoc adds higher-level document layout capabilities.
Choosing the Right .NET PDF Library
Frequently Asked Questions
Which .NET PDF library is free for commercial use?
PdfPig (Apache 2.0) and PDFsharp (MIT) are free for commercial use. iText 7 is AGPL and requires a commercial license for closed-source products. ComPDF and Aspose are commercial SDKs available with trial licenses.
Can I use iText 7 for free in a commercial .NET project?
Only if your project is open-source and compliant with AGPL terms. For proprietary commercial applications, iText 7 requires a paid commercial license from iText Group.
What is the difference between ComPDFKit.NetFramework and ComPDFKit_Conversion.NetFramework?
ComPDFKit.NetFramework provides the core viewer, annotation, forms, and digital signature features. ComPDFKit_Conversion.NetFramework is a separate add-on for PDF-to-Office conversion (Word, Excel, PowerPoint) with optional AI-powered layout recognition.
Does PdfPig support editing or signing PDFs?
No. PdfPig supports text extraction, metadata reading, and basic PDF document creation. It cannot edit existing PDFs, fill forms, or add digital signatures. For those workflows, use a full-featured SDK such as ComPDF, iText 7, or Aspose.PDF.
Summary
If your project needs full lifecycle PDF capabilities in .NET, ComPDF and Aspose are practical top choices. If your scope is generation-only, iText 7 remains mature. If extraction is the sole goal, PdfPig is lightweight and permissively licensed.