Skip to footer content
MIGRATION GUIDES

How to Migrate from ComPDFKit to IronPDF in C#

While ComPDFKit offers solid PDF manipulation features, several factors drive development teams to consider more established alternatives.

Market Maturity and Ecosystem Comparison

ComPDFKit faces challenges common to newer market entrants: documentation gaps, a smaller community, and limited Stack Overflow coverage. IronPDF's decade of refinement provides the stability and resources enterprise projects require.

AspectComPDFKitIronPDF
HTML-to-PDFRequires manual HTML parsingNative Chromium rendering
Market MaturityNewer entrant10+ years, battle-tested
Community SizeSmaller, limited Stack OverflowLarge, active community
DocumentationSome gapsExtensive tutorials & guides
DownloadsGrowing10+ million NuGet downloads
API StyleC++ influenced, verboseModern .NET fluent API
Memory ManagementManual Release() callsAutomatic GC handling

Feature Parity

Both libraries support comprehensive PDF functionality:

FeatureComPDFKitIronPDF
HTML to PDFBasic/Manual✅ Native Chromium
URL to PDFManual implementation✅ Built-in
Create PDF from scratch
PDF editing
Text extraction
Merge/Split
Digital signatures
Form filling
Watermarks
Cross-platformWindows, Linux, macOSWindows, Linux, macOS

Key Migration Benefits

  1. Superior HTML Rendering: IronPDF's Chromium engine handles modern CSS3, JavaScript, and responsive layouts natively
  2. Mature Ecosystem: 10+ years of refinement, extensive documentation, and proven stability
  3. Simpler API: Less boilerplate code, no manual memory management with Release() calls
  4. Better .NET Integration: Native async/await, LINQ support, fluent interfaces
  5. Extensive Resources: Thousands of Stack Overflow answers and community examples

Pre-Migration Preparation

Prerequisites

Ensure your environment meets these requirements:

  • .NET Framework 4.6.2+ or .NET Core 3.1 / .NET 5-9
  • Visual Studio 2019+ or VS Code with C# extension
  • NuGet Package Manager access
  • IronPDF license key (free trial available at ironpdf.com)

Audit ComPDFKit Usage

Run these commands in your solution directory to identify all ComPDFKit references:

# Find all ComPDFKit usages in your codebase
grep -r "using ComPDFKit" --include="*.cs" .
grep -r "CPDFDocument\|CPDFPage\|CPDFAnnotation" --include="*.cs" .

# Find NuGet package references
grep -r "ComPDFKit" --include="*.csproj" .
# Find all ComPDFKit usages in your codebase
grep -r "using ComPDFKit" --include="*.cs" .
grep -r "CPDFDocument\|CPDFPage\|CPDFAnnotation" --include="*.cs" .

# Find NuGet package references
grep -r "ComPDFKit" --include="*.csproj" .
SHELL

Breaking Changes to Anticipate

ChangeComPDFKitIronPDFImpact
Document loadingCPDFDocument.InitWithFilePath()PdfDocument.FromFile()Method name change
Savingdocument.WriteToFilePath()pdf.SaveAs()Method name change
Memory cleanupdocument.Release() requiredAutomatic (GC)Remove manual cleanup
Page accessdocument.PageAtIndex(i)pdf.Pages[i]Array-style access
Page indexing0-based0-basedNo change needed
HTML renderingManual implementationRenderHtmlAsPdf()Major simplification
Text extractiontextPage.GetText()pdf.ExtractAllText()Simplified API

Step-by-Step Migration Process

Step 1: Update NuGet Packages

Remove ComPDFKit packages and install IronPDF:

# Remove ComPDFKit packages
dotnet remove package ComPDFKit.NetCore
dotnet remove package ComPDFKit.NetFramework

# Install IronPDF
dotnet add package IronPdf
# Remove ComPDFKit packages
dotnet remove package ComPDFKit.NetCore
dotnet remove package ComPDFKit.NetFramework

# Install IronPDF
dotnet add package IronPdf
SHELL

Step 2: Update Namespace References

Replace ComPDFKit namespaces with IronPDF:

// Remove these
using ComPDFKit.PDFDocument;
using ComPDFKit.PDFPage;
using ComPDFKit.PDFAnnotation;
using ComPDFKit.Import;

// Add this
using IronPdf;
// Remove these
using ComPDFKit.PDFDocument;
using ComPDFKit.PDFPage;
using ComPDFKit.PDFAnnotation;
using ComPDFKit.Import;

// Add this
using IronPdf;
$vbLabelText   $csharpLabel

Step 3: Configure License

// Add at application startup (Program.cs or Global.asax)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Global.asax)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
$vbLabelText   $csharpLabel

Complete API Migration Reference

Document Operations

TaskComPDFKitIronPDF
Create empty documentCPDFDocument.CreateDocument()new PdfDocument()
Load from fileCPDFDocument.InitWithFilePath(path)PdfDocument.FromFile(path)
Load from streamCPDFDocument.InitWithStream(stream)PdfDocument.FromStream(stream)
Save to filedocument.WriteToFilePath(path)pdf.SaveAs(path)
Get page countdocument.PageCountpdf.PageCount
Release/Disposedocument.Release()Not required

HTML to PDF Conversion

TaskComPDFKitIronPDF
HTML string to PDFManual implementation requiredrenderer.RenderHtmlAsPdf(html)
HTML file to PDFManual implementation requiredrenderer.RenderHtmlFileAsPdf(path)
URL to PDFManual implementation requiredrenderer.RenderUrlAsPdf(url)
Set page sizeVia page creation parametersrenderer.RenderingOptions.PaperSize
Set marginsVia editor configurationrenderer.RenderingOptions.MarginTop etc.

Merge and Split Operations

TaskComPDFKitIronPDF
Merge documentsdoc1.ImportPagesAtIndex(doc2, range, index)PdfDocument.Merge(pdf1, pdf2)
Split documentExtract pages to new documentpdf.CopyPages(start, end)

Code Migration Examples

HTML to PDF Conversion

The most significant difference between ComPDFKit and IronPDF is HTML rendering. ComPDFKit requires manual text placement, while IronPDF renders HTML natively with its Chromium engine.

ComPDFKit Implementation:

// NuGet: Install-Package ComPDFKit.NetCore
using ComPDFKit.PDFDocument;
using System;

class Program
{
    static void Main()
    {
        var document = CPDFDocument.CreateDocument();
        var page = document.InsertPage(0, 595, 842, "");

        // ComPDFKit requires manual HTML rendering
        // Native HTML to PDF not directly supported
        var editor = page.GetEditor();
        editor.BeginEdit(CPDFEditType.EditText);
        editor.CreateTextWidget(new System.Drawing.RectangleF(50, 50, 500, 700), "HTML content here");
        editor.EndEdit();

        document.WriteToFilePath("output.pdf");
        document.Release();
    }
}
// NuGet: Install-Package ComPDFKit.NetCore
using ComPDFKit.PDFDocument;
using System;

class Program
{
    static void Main()
    {
        var document = CPDFDocument.CreateDocument();
        var page = document.InsertPage(0, 595, 842, "");

        // ComPDFKit requires manual HTML rendering
        // Native HTML to PDF not directly supported
        var editor = page.GetEditor();
        editor.BeginEdit(CPDFEditType.EditText);
        editor.CreateTextWidget(new System.Drawing.RectangleF(50, 50, 500, 700), "HTML content here");
        editor.EndEdit();

        document.WriteToFilePath("output.pdf");
        document.Release();
    }
}
$vbLabelText   $csharpLabel

IronPDF Implementation:

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is HTML content.</p>");
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is HTML content.</p>");
        pdf.SaveAs("output.pdf");
    }
}
$vbLabelText   $csharpLabel

IronPDF's ChromePdfRenderer eliminates the need for manual text positioning and editor management. For more HTML conversion options, see the HTML to PDF documentation.

Merging Multiple PDFs

ComPDFKit Implementation:

// NuGet: Install-Package ComPDFKit.NetCore
using ComPDFKit.PDFDocument;
using ComPDFKit.Import;
using System;

class Program
{
    static void Main()
    {
        var document1 = CPDFDocument.InitWithFilePath("file1.pdf");
        var document2 = CPDFDocument.InitWithFilePath("file2.pdf");

        // Import pages from document2 into document1
        document1.ImportPagesAtIndex(document2, "0-" + (document2.PageCount - 1), document1.PageCount);

        document1.WriteToFilePath("merged.pdf");
        document1.Release();
        document2.Release();
    }
}
// NuGet: Install-Package ComPDFKit.NetCore
using ComPDFKit.PDFDocument;
using ComPDFKit.Import;
using System;

class Program
{
    static void Main()
    {
        var document1 = CPDFDocument.InitWithFilePath("file1.pdf");
        var document2 = CPDFDocument.InitWithFilePath("file2.pdf");

        // Import pages from document2 into document1
        document1.ImportPagesAtIndex(document2, "0-" + (document2.PageCount - 1), document1.PageCount);

        document1.WriteToFilePath("merged.pdf");
        document1.Release();
        document2.Release();
    }
}
$vbLabelText   $csharpLabel

IronPDF Implementation:

// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("file1.pdf");
        var pdf2 = PdfDocument.FromFile("file2.pdf");

        var merged = PdfDocument.Merge(new List<PdfDocument> { pdf1, pdf2 });
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("file1.pdf");
        var pdf2 = PdfDocument.FromFile("file2.pdf");

        var merged = PdfDocument.Merge(new List<PdfDocument> { pdf1, pdf2 });
        merged.SaveAs("merged.pdf");
    }
}
$vbLabelText   $csharpLabel

IronPDF's static Merge method eliminates the verbose ImportPagesAtIndex pattern with page range strings. For more options, see the PDF merging documentation.

Adding Watermarks

Watermarking demonstrates the paradigm shift from ComPDFKit's editor-based approach to IronPDF's HTML-based styling.

ComPDFKit Implementation:

// NuGet: Install-Package ComPDFKit.NetCore
using ComPDFKit.PDFDocument;
using ComPDFKit.PDFPage;
using System;
using System.Drawing;

class Program
{
    static void Main()
    {
        var document = CPDFDocument.InitWithFilePath("input.pdf");

        for (int i = 0; i < document.PageCount; i++)
        {
            var page = document.PageAtIndex(i);
            var editor = page.GetEditor();
            editor.BeginEdit(CPDFEditType.EditText);

            var textArea = editor.CreateTextArea();
            textArea.SetText("CONFIDENTIAL");
            textArea.SetFontSize(48);
            textArea.SetTransparency(128);

            editor.EndEdit();
            page.Release();
        }

        document.WriteToFilePath("watermarked.pdf");
        document.Release();
    }
}
// NuGet: Install-Package ComPDFKit.NetCore
using ComPDFKit.PDFDocument;
using ComPDFKit.PDFPage;
using System;
using System.Drawing;

class Program
{
    static void Main()
    {
        var document = CPDFDocument.InitWithFilePath("input.pdf");

        for (int i = 0; i < document.PageCount; i++)
        {
            var page = document.PageAtIndex(i);
            var editor = page.GetEditor();
            editor.BeginEdit(CPDFEditType.EditText);

            var textArea = editor.CreateTextArea();
            textArea.SetText("CONFIDENTIAL");
            textArea.SetFontSize(48);
            textArea.SetTransparency(128);

            editor.EndEdit();
            page.Release();
        }

        document.WriteToFilePath("watermarked.pdf");
        document.Release();
    }
}
$vbLabelText   $csharpLabel

IronPDF Implementation:

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        pdf.ApplyWatermark("<h1 style='color:rgba(255,0,0,0.3);'>CONFIDENTIAL</h1>",
            rotation: 45,
            verticalAlignment: VerticalAlignment.Middle,
            horizontalAlignment: HorizontalAlignment.Center);

        pdf.SaveAs("watermarked.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");

        pdf.ApplyWatermark("<h1 style='color:rgba(255,0,0,0.3);'>CONFIDENTIAL</h1>",
            rotation: 45,
            verticalAlignment: VerticalAlignment.Middle,
            horizontalAlignment: HorizontalAlignment.Center);

        pdf.SaveAs("watermarked.pdf");
    }
}
$vbLabelText   $csharpLabel

IronPDF reduces a 20+ line watermark implementation to a single method call with HTML/CSS styling. For more options, see the watermark documentation.

Text Extraction

ComPDFKit Implementation:

using ComPDFKit.PDFDocument;
using System.Text;

var document = CPDFDocument.InitWithFilePath("document.pdf");

// Extract text (verbose)
var allText = new StringBuilder();
for (int i = 0; i < document.PageCount; i++)
{
    var page = document.PageAtIndex(i);
    var textPage = page.GetTextPage();
    allText.AppendLine(textPage.GetText(0, textPage.CountChars()));
    textPage.Release();
    page.Release();
}

document.WriteToFilePath("output.pdf");
document.Release(); // Must remember to release!
using ComPDFKit.PDFDocument;
using System.Text;

var document = CPDFDocument.InitWithFilePath("document.pdf");

// Extract text (verbose)
var allText = new StringBuilder();
for (int i = 0; i < document.PageCount; i++)
{
    var page = document.PageAtIndex(i);
    var textPage = page.GetTextPage();
    allText.AppendLine(textPage.GetText(0, textPage.CountChars()));
    textPage.Release();
    page.Release();
}

document.WriteToFilePath("output.pdf");
document.Release(); // Must remember to release!
$vbLabelText   $csharpLabel

IronPDF Implementation:

using IronPdf;

var pdf = PdfDocument.FromFile("document.pdf");

// Extract text (one-liner)
string allText = pdf.ExtractAllText();

pdf.SaveAs("output.pdf");
// No Release() needed - GC handles cleanup
using IronPdf;

var pdf = PdfDocument.FromFile("document.pdf");

// Extract text (one-liner)
string allText = pdf.ExtractAllText();

pdf.SaveAs("output.pdf");
// No Release() needed - GC handles cleanup
$vbLabelText   $csharpLabel

IronPDF reduces multi-line text extraction with manual Release() calls to a single method. For more extraction options, see the text extraction documentation.

Password Protection

IronPDF Implementation:

using IronPdf;

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential Document</h1>");

// Set security
pdf.SecuritySettings.UserPassword = "userPassword";
pdf.SecuritySettings.OwnerPassword = "ownerPassword";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;

pdf.SaveAs("protected.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Confidential Document</h1>");

// Set security
pdf.SecuritySettings.UserPassword = "userPassword";
pdf.SecuritySettings.OwnerPassword = "ownerPassword";
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;

pdf.SaveAs("protected.pdf");
$vbLabelText   $csharpLabel

For comprehensive security options, see the encryption documentation.

Critical Migration Notes

Remove All Release() Calls

The most impactful change is removing manual memory management. ComPDFKit requires explicit Release() calls on documents, pages, and text pages. IronPDF handles this automatically through .NET garbage collection:

// ComPDFKit - manual cleanup required
document.Release();
page.Release();
textPage.Release();

// IronPDF - no equivalent needed
// GC handles cleanup automatically
// ComPDFKit - manual cleanup required
document.Release();
page.Release();
textPage.Release();

// IronPDF - no equivalent needed
// GC handles cleanup automatically
$vbLabelText   $csharpLabel

Native HTML Rendering

ComPDFKit requires manual text placement with editor APIs. IronPDF renders HTML/CSS natively with its Chromium engine, supporting modern CSS3, JavaScript, and responsive layouts.

Same Page Indexing

Both libraries use 0-based indexing (Pages[0] is the first page)—no changes needed for page access code.

Simplified Text Extraction

Replace the multi-line GetTextPage() + GetText() + Release() pattern with a single ExtractAllText() call.

Fluent Merge API

Replace ImportPagesAtIndex(doc2, "0-9", pageCount) with simple Merge(pdf1, pdf2).

Post-Migration Checklist

After completing the code migration, verify the following:

  • Run all unit tests to verify PDF generation works correctly
  • Compare PDF output quality (IronPDF's Chromium engine may render differently—usually better)
  • Test HTML rendering with complex CSS and JavaScript
  • Verify text extraction accuracy
  • Test form functionality
  • Performance test batch operations
  • Test in all target environments
  • Update CI/CD pipelines
  • Remove ComPDFKit license files

Future-Proofing Your PDF Infrastructure

With .NET 10 on the horizon and C# 14 introducing new language features, choosing a mature, actively maintained PDF library ensures long-term compatibility. IronPDF's 10+ year track record, extensive community support, and modern API design means your migration investment pays dividends as projects extend into 2025 and 2026.

Additional Resources


Migrating from ComPDFKit to IronPDF eliminates manual memory management with Release() calls while providing native HTML-to-PDF rendering that ComPDFKit lacks. The transition to IronPDF's mature ecosystem delivers the documentation depth, community support, and proven stability that enterprise projects require.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...

Read More