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.

Aspect ComPDFKit IronPDF
HTML-to-PDF Requires manual HTML parsing Native Chromium rendering
Market Maturity Newer entrant 10+ years, battle-tested
Community Size Smaller, limited Stack Overflow Large, active community
Documentation Some gaps Extensive tutorials & guides
Downloads Growing 10+ million NuGet downloads
API Style C++ influenced, verbose Modern .NET fluent API
Memory Management Manual Release() calls Automatic GC handling

Feature Parity

Both libraries support comprehensive PDF functionality:

Feature ComPDFKit IronPDF
HTML to PDF Basic/Manual ✅ Native Chromium
URL to PDF Manual implementation ✅ Built-in
Create PDF from scratch
PDF editing
Text extraction
Merge/Split
Digital signatures
Form filling
Watermarks
Cross-platform Windows, Linux, macOS Windows, 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

Change ComPDFKit IronPDF Impact
Document loading CPDFDocument.InitWithFilePath() PdfDocument.FromFile() Method name change
Saving document.WriteToFilePath() pdf.SaveAs() Method name change
Memory cleanup document.Release() required Automatic (GC) Remove manual cleanup
Page access document.PageAtIndex(i) pdf.Pages[i] Array-style access
Page indexing 0-based 0-based No change needed
HTML rendering Manual implementation RenderHtmlAsPdf() Major simplification
Text extraction textPage.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;
Imports 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";
' Add at application startup (Program.vb or Global.asax)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

Complete API Migration Reference

Document Operations

Task ComPDFKit IronPDF
Create empty document CPDFDocument.CreateDocument() new PdfDocument()
Load from file CPDFDocument.InitWithFilePath(path) PdfDocument.FromFile(path)
Load from stream CPDFDocument.InitWithStream(stream) PdfDocument.FromStream(stream)
Save to file document.WriteToFilePath(path) pdf.SaveAs(path)
Get page count document.PageCount pdf.PageCount
Release/Dispose document.Release() Not required

HTML to PDF Conversion

Task ComPDFKit IronPDF
HTML string to PDF Manual implementation required renderer.RenderHtmlAsPdf(html)
HTML file to PDF Manual implementation required renderer.RenderHtmlFileAsPdf(path)
URL to PDF Manual implementation required renderer.RenderUrlAsPdf(url)
Set page size Via page creation parameters renderer.RenderingOptions.PaperSize
Set margins Via editor configuration renderer.RenderingOptions.MarginTop etc.

Merge and Split Operations

Task ComPDFKit IronPDF
Merge documents doc1.ImportPagesAtIndex(doc2, range, index) PdfDocument.Merge(pdf1, pdf2)
Split document Extract pages to new document pdf.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();
    }
}
Imports ComPDFKit.PDFDocument
Imports System
Imports System.Drawing

Module Program
    Sub Main()
        Dim document = CPDFDocument.CreateDocument()
        Dim page = document.InsertPage(0, 595, 842, "")

        ' ComPDFKit requires manual HTML rendering
        ' Native HTML to PDF not directly supported
        Dim editor = page.GetEditor()
        editor.BeginEdit(CPDFEditType.EditText)
        editor.CreateTextWidget(New RectangleF(50, 50, 500, 700), "HTML content here")
        editor.EndEdit()

        document.WriteToFilePath("output.pdf")
        document.Release()
    End Sub
End Module
$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");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1><p>This is HTML content.</p>")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$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();
    }
}
Imports ComPDFKit.PDFDocument
Imports ComPDFKit.Import
Imports System

Module Program
    Sub Main()
        Dim document1 = CPDFDocument.InitWithFilePath("file1.pdf")
        Dim 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()
    End Sub
End Module
$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");
    }
}
Imports IronPdf
Imports System
Imports System.Collections.Generic

Module Program
    Sub Main()
        Dim pdf1 = PdfDocument.FromFile("file1.pdf")
        Dim pdf2 = PdfDocument.FromFile("file2.pdf")

        Dim merged = PdfDocument.Merge(New List(Of PdfDocument) From {pdf1, pdf2})
        merged.SaveAs("merged.pdf")
    End Sub
End Module
$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();
    }
}
Imports ComPDFKit.PDFDocument
Imports ComPDFKit.PDFPage
Imports System
Imports System.Drawing

Module Program
    Sub Main()
        Dim document = CPDFDocument.InitWithFilePath("input.pdf")

        For i As Integer = 0 To document.PageCount - 1
            Dim page = document.PageAtIndex(i)
            Dim editor = page.GetEditor()
            editor.BeginEdit(CPDFEditType.EditText)

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

            editor.EndEdit()
            page.Release()
        Next

        document.WriteToFilePath("watermarked.pdf")
        document.Release()
    End Sub
End Module
$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");
    }
}
Imports IronPdf
Imports IronPdf.Editing
Imports System

Module Program
    Sub Main()
        Dim 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")
    End Sub
End Module
$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!
Imports ComPDFKit.PDFDocument
Imports System.Text

Dim document = CPDFDocument.InitWithFilePath("document.pdf")

' Extract text (verbose)
Dim allText As New StringBuilder()
For i As Integer = 0 To document.PageCount - 1
    Dim page = document.PageAtIndex(i)
    Dim textPage = page.GetTextPage()
    allText.AppendLine(textPage.GetText(0, textPage.CountChars()))
    textPage.Release()
    page.Release()
Next

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
Imports IronPdf

Dim pdf = PdfDocument.FromFile("document.pdf")

' Extract text (one-liner)
Dim allText As String = 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");
Imports IronPdf

Dim renderer As New ChromePdfRenderer()
Dim 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

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me