Skip to footer content
MIGRATION GUIDES

Migrate from Foxit PDF SDK to IronPDF: (.NET Guide)

Migrating from Foxit PDF SDK to IronPDF simplifies your .NET PDF generation workflow by replacing complex enterprise-focused APIs with modern, developer-friendly patterns. This guide provides a full, step-by-step migration path that removes unnecessary code and makes PDF operations easier across your codebase.

Why Migrate from Foxit PDF SDK to IronPDF

The Foxit PDF Challenges

Foxit PDF SDK is a strong enterprise-level library, but it comes with significant complexity that can slow down development:

  1. Complex Licensing System: Multiple products, SKUs, and license types (per-developer, per-server, OEM, etc.) make it difficult to choose the right option for your project.

  2. Enterprise Pricing: Pricing is tailored for large organizations and can be prohibitive for smaller teams or individual developers.

  3. Manual Installation: Foxit PDF SDK requires manual DLL references or private NuGet feeds—there's no simple public NuGet package available.

  4. Verbose API: Library initialization with Library.Initialize(), error code checking, and explicit Library.Release() calls add substantial boilerplate to every operation.

  5. Separate HTML Conversion Add-on: HTML to PDF conversion requires an additional add-on purchase—it's not included in the base SDK.

  6. Complex Configuration: Settings require detailed object configuration (e.g., HTML2PDFSettingData) with multiple properties.

  7. C++ Heritage: API patterns reflect C++ origins, feeling less natural in modern C# applications.

Foxit PDF vs IronPDF Comparison

AspectFoxit PDF SDKIronPDF
InstallationManual DLLs/private feedsSimple NuGet package
LicensingComplex, enterprise-focusedTransparent, suitable for all sizes
InitializationLibrary.Initialize(sn, key)Set license key once
Error HandlingErrorCode enumsStandard .NET exceptions
HTML to PDFSeparate add-on purchaseBuilt-in Chromium engine
API StyleC++ heritage, verboseModern .NET patterns
Resource CleanupManual Close()/Release()IDisposable/automatic
DocumentationEnterprise docs portalPublic tutorials

Cost-Benefit Analysis

Moving from Foxit PDF to IronPDF offers tangible development benefits: reduced complexity through simpler APIs, faster development with intuitive methods, modern .NET compatibility including async/await and LINQ support, an HTML-first approach that uses existing web skills, and all-inclusive features without separate add-on purchases. As you plan for .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides a future-proof foundation for PDF generation.


Before You Start

Prerequisites

  1. .NET Environment: IronPDF supports .NET Framework 4.6.2+, .NET Core 3.1+, .NET 5/6/7/8/9+
  2. NuGet Access: Ensure you can install packages from NuGet
  3. License Key: Obtain your IronPDF license key for production use from ironpdf.com

Backup Your Project

# Create a backup branch
git checkout -b pre-ironpdf-migration
git add .
git commit -m "Backup before Foxit PDF SDK to IronPDF migration"
# Create a backup branch
git checkout -b pre-ironpdf-migration
git add .
git commit -m "Backup before Foxit PDF SDK to IronPDF migration"
SHELL

Identify All Foxit PDF Usage

# Find all Foxit PDF SDK references
grep -r "foxit\|PDFDoc\|PDFPage\|Library.Initialize\|Library.Release" --include="*.cs" --include="*.csproj" .

# Find Foxit DLL references
find . -name "*.csproj" | xargs grep -l "Foxit\|fsdk"
# Find all Foxit PDF SDK references
grep -r "foxit\|PDFDoc\|PDFPage\|Library.Initialize\|Library.Release" --include="*.cs" --include="*.csproj" .

# Find Foxit DLL references
find . -name "*.csproj" | xargs grep -l "Foxit\|fsdk"
SHELL

Document Current Functionality

Before migration, catalog:

  • Which Foxit PDF features you use (HTML conversion, annotations, forms, security)
  • License key locations and initialization code
  • Custom configurations and settings
  • Error handling patterns using ErrorCode enums

Quick Start Migration

Step 1: Update NuGet Packages

# Foxit PDF SDK typically requires manual removal of DLL references
# Check your .csproj for Foxit references and remove them

# Install IronPDF
dotnet add package IronPdf
# Foxit PDF SDK typically requires manual removal of DLL references
# Check your .csproj for Foxit references and remove them

# Install IronPDF
dotnet add package IronPdf
SHELL

If you have Foxit PDF references in .csproj, remove them manually:


<Reference Include="fsdk_dotnet">
    <HintPath>..\libs\Foxit\fsdk_dotnet.dll</HintPath>
</Reference>

<Reference Include="fsdk_dotnet">
    <HintPath>..\libs\Foxit\fsdk_dotnet.dll</HintPath>
</Reference>
XML

Step 2: Update Namespaces

// Before (Foxit PDF)
using foxit;
using foxit.common;
using foxit.common.fxcrt;
using foxit.pdf;
using foxit.pdf.annots;
using foxit.addon.conversion;

// After (IronPDF)
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;
// Before (Foxit PDF)
using foxit;
using foxit.common;
using foxit.common.fxcrt;
using foxit.pdf;
using foxit.pdf.annots;
using foxit.addon.conversion;

// After (IronPDF)
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;
Imports IronPdf
Imports IronPdf.Rendering
Imports IronPdf.Editing
$vbLabelText   $csharpLabel

Step 3: Initialize IronPDF

One of the most significant improvements in this Foxit PDF migration is eliminating the complex initialization and cleanup pattern:

// Before (Foxit PDF)
string sn = "YOUR_SERIAL_NUMBER";
string key = "YOUR_LICENSE_KEY";
ErrorCode error_code = Library.Initialize(sn, key);
if (error_code != ErrorCode.e_ErrSuccess)
{
    throw new Exception("Failed to initialize Foxit PDF SDK");
}
// ... your code ...
Library.Release();  // Don't forget this!

// After (IronPDF)
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
// That's it! No Release() needed
// Before (Foxit PDF)
string sn = "YOUR_SERIAL_NUMBER";
string key = "YOUR_LICENSE_KEY";
ErrorCode error_code = Library.Initialize(sn, key);
if (error_code != ErrorCode.e_ErrSuccess)
{
    throw new Exception("Failed to initialize Foxit PDF SDK");
}
// ... your code ...
Library.Release();  // Don't forget this!

// After (IronPDF)
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
// That's it! No Release() needed
' Before (Foxit PDF)
Dim sn As String = "YOUR_SERIAL_NUMBER"
Dim key As String = "YOUR_LICENSE_KEY"
Dim error_code As ErrorCode = Library.Initialize(sn, key)
If error_code <> ErrorCode.e_ErrSuccess Then
    Throw New Exception("Failed to initialize Foxit PDF SDK")
End If
' ... your code ...
Library.Release()  ' Don't forget this!

' After (IronPDF)
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"
' That's it! No Release() needed
$vbLabelText   $csharpLabel

Step 4: Basic Conversion Pattern

// Before (Foxit PDF)
Library.Initialize(sn, key);
HTML2PDFSettingData settings = new HTML2PDFSettingData();
settings.page_width = 612.0f;
settings.page_height = 792.0f;
using (HTML2PDF html2pdf = new HTML2PDF(settings))
{
    html2pdf.Convert(htmlContent, "output.pdf");
}
Library.Release();

// After (IronPDF)
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
// Before (Foxit PDF)
Library.Initialize(sn, key);
HTML2PDFSettingData settings = new HTML2PDFSettingData();
settings.page_width = 612.0f;
settings.page_height = 792.0f;
using (HTML2PDF html2pdf = new HTML2PDF(settings))
{
    html2pdf.Convert(htmlContent, "output.pdf");
}
Library.Release();

// After (IronPDF)
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
Imports FoxitPDF
Imports IronPdf

' Before (Foxit PDF)
Library.Initialize(sn, key)
Dim settings As New HTML2PDFSettingData()
settings.page_width = 612.0F
settings.page_height = 792.0F
Using html2pdf As New HTML2PDF(settings)
    html2pdf.Convert(htmlContent, "output.pdf")
End Using
Library.Release()

' After (IronPDF)
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
pdf.SaveAs("output.pdf")
$vbLabelText   $csharpLabel

Complete API Reference

Namespace Mapping

Foxit PDF NamespaceIronPDF Equivalent
foxitIronPdf
foxit.commonIronPdf
foxit.common.fxcrtN/A
foxit.pdfIronPdf
foxit.pdf.annotsIronPdf.Editing
foxit.addon.conversionIronPdf.Rendering

Core Class Mapping

Foxit PDF SDK ClassIronPDF Equivalent
LibraryN/A
PDFDocPdfDocument
PDFPagePdfDocument.Pages[i]
HTML2PDFChromePdfRenderer
TextPagepdf.ExtractTextFromPage(i)
WatermarkTextStamper / ImageStamper
SecuritySecuritySettings
Formpdf.Form
Metadatapdf.MetaData

PDFDoc Methods

Foxit PDFDocIronPDF PdfDocument
new PDFDoc(path)PdfDocument.FromFile(path)
doc.LoadW(password)PdfDocument.FromFile(path, password)
doc.GetPageCount()pdf.PageCount
doc.GetPage(index)pdf.Pages[index]
doc.SaveAs(path, flags)pdf.SaveAs(path)
doc.Close()pdf.Dispose() or using statement
doc.InsertDocument()PdfDocument.Merge()

HTML2PDF / Conversion

Foxit HTML2PDFIronPDF Equivalent
new HTML2PDFSettingData()new ChromePdfRenderer()
settings.page_widthRenderingOptions.PaperSize
settings.page_heightRenderingOptions.SetCustomPaperSize()
html2pdf.Convert(html, path)renderer.RenderHtmlAsPdf(html)
html2pdf.ConvertFromURL(url, path)renderer.RenderUrlAsPdf(url)

Watermark Settings

Foxit WatermarkIronPDF Equivalent
new Watermark(doc, text, font, size, color)new TextStamper()
WatermarkSettings.positionVerticalAlignment + HorizontalAlignment
WatermarkSettings.rotationRotation
WatermarkSettings.opacityOpacity
watermark.InsertToAllPages()pdf.ApplyStamp(stamper)

Code Examples

Example 1: HTML to PDF Conversion

Before (Foxit PDF SDK):

// NuGet: Install-Package Foxit.SDK
using Foxit.SDK;
using Foxit.SDK.Common;
using Foxit.SDK.PDFConversion;
using System;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        HTML2PDFSettingData settingData = new HTML2PDFSettingData();
        settingData.page_width = 612.0f;
        settingData.page_height = 792.0f;
        settingData.page_mode = HTML2PDFPageMode.e_HTML2PDFPageModeSinglePage;

        using (HTML2PDF html2pdf = new HTML2PDF(settingData))
        {
            html2pdf.Convert("<html><body><h1>Hello World</h1></body></html>", "output.pdf");
        }

        Library.Release();
    }
}
// NuGet: Install-Package Foxit.SDK
using Foxit.SDK;
using Foxit.SDK.Common;
using Foxit.SDK.PDFConversion;
using System;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        HTML2PDFSettingData settingData = new HTML2PDFSettingData();
        settingData.page_width = 612.0f;
        settingData.page_height = 792.0f;
        settingData.page_mode = HTML2PDFPageMode.e_HTML2PDFPageModeSinglePage;

        using (HTML2PDF html2pdf = new HTML2PDF(settingData))
        {
            html2pdf.Convert("<html><body><h1>Hello World</h1></body></html>", "output.pdf");
        }

        Library.Release();
    }
}
Imports Foxit.SDK
Imports Foxit.SDK.Common
Imports Foxit.SDK.PDFConversion
Imports System

Class Program
    Shared Sub Main()
        Library.Initialize("sn", "key")

        Dim settingData As New HTML2PDFSettingData()
        settingData.page_width = 612.0F
        settingData.page_height = 792.0F
        settingData.page_mode = HTML2PDFPageMode.e_HTML2PDFPageModeSinglePage

        Using html2pdf As New HTML2PDF(settingData)
            html2pdf.Convert("<html><body><h1>Hello World</h1></body></html>", "output.pdf")
        End Using

        Library.Release()
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1></body></html>");
        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("<html><body><h1>Hello World</h1></body></html>");
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderHtmlAsPdf("<html><body><h1>Hello World</h1></body></html>")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

The IronPDF approach reduces 15+ lines of configuration code to just 4 lines. No library initialization, no explicit cleanup, no complex settings objects. For more HTML rendering options, see the HTML to PDF documentation.

Example 2: URL to PDF Conversion

Before (Foxit PDF SDK):

// NuGet: Install-Package Foxit.SDK
using Foxit.SDK;
using Foxit.SDK.Common;
using Foxit.SDK.PDFConversion;
using System;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        HTML2PDFSettingData settingData = new HTML2PDFSettingData();
        settingData.page_width = 612.0f;
        settingData.page_height = 792.0f;
        settingData.page_mode = HTML2PDFPageMode.e_HTML2PDFPageModeSinglePage;

        using (HTML2PDF html2pdf = new HTML2PDF(settingData))
        {
            html2pdf.ConvertFromURL("https://www.example.com", "output.pdf");
        }

        Library.Release();
    }
}
// NuGet: Install-Package Foxit.SDK
using Foxit.SDK;
using Foxit.SDK.Common;
using Foxit.SDK.PDFConversion;
using System;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        HTML2PDFSettingData settingData = new HTML2PDFSettingData();
        settingData.page_width = 612.0f;
        settingData.page_height = 792.0f;
        settingData.page_mode = HTML2PDFPageMode.e_HTML2PDFPageModeSinglePage;

        using (HTML2PDF html2pdf = new HTML2PDF(settingData))
        {
            html2pdf.ConvertFromURL("https://www.example.com", "output.pdf");
        }

        Library.Release();
    }
}
Imports Foxit.SDK
Imports Foxit.SDK.Common
Imports Foxit.SDK.PDFConversion
Imports System

Class Program
    Shared Sub Main()
        Library.Initialize("sn", "key")

        Dim settingData As New HTML2PDFSettingData()
        settingData.page_width = 612.0F
        settingData.page_height = 792.0F
        settingData.page_mode = HTML2PDFPageMode.e_HTML2PDFPageModeSinglePage

        Using html2pdf As New HTML2PDF(settingData)
            html2pdf.ConvertFromURL("https://www.example.com", "output.pdf")
        End Using

        Library.Release()
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF's built-in Chromium engine handles JavaScript execution, CSS rendering, and dynamic content automatically. Learn more about URL to PDF conversion.

Example 3: Adding Watermarks

Before (Foxit PDF SDK):

// NuGet: Install-Package Foxit.SDK
using Foxit.SDK;
using Foxit.SDK.Common;
using Foxit.SDK.PDFDoc;
using System;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            doc.Load("");

            Watermark watermark = new Watermark(doc, "Confidential", 
                new Font(Font.StandardID.e_StdIDHelvetica), 48.0f, 0xFF0000FF);

            WatermarkSettings settings = new WatermarkSettings();
            settings.flags = Watermark.e_WatermarkFlagASPageContents;
            settings.position = Watermark.Position.e_PosCenter;
            settings.rotation = -45.0f;
            settings.opacity = 0.5f;

            watermark.SetSettings(settings);
            watermark.InsertToAllPages();

            doc.SaveAs("output.pdf", PDFDoc.SaveFlags.e_SaveFlagNoOriginal);
        }

        Library.Release();
    }
}
// NuGet: Install-Package Foxit.SDK
using Foxit.SDK;
using Foxit.SDK.Common;
using Foxit.SDK.PDFDoc;
using System;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        using (PDFDoc doc = new PDFDoc("input.pdf"))
        {
            doc.Load("");

            Watermark watermark = new Watermark(doc, "Confidential", 
                new Font(Font.StandardID.e_StdIDHelvetica), 48.0f, 0xFF0000FF);

            WatermarkSettings settings = new WatermarkSettings();
            settings.flags = Watermark.e_WatermarkFlagASPageContents;
            settings.position = Watermark.Position.e_PosCenter;
            settings.rotation = -45.0f;
            settings.opacity = 0.5f;

            watermark.SetSettings(settings);
            watermark.InsertToAllPages();

            doc.SaveAs("output.pdf", PDFDoc.SaveFlags.e_SaveFlagNoOriginal);
        }

        Library.Release();
    }
}
Imports Foxit.SDK
Imports Foxit.SDK.Common
Imports Foxit.SDK.PDFDoc
Imports System

Class Program
    Shared Sub Main()
        Library.Initialize("sn", "key")

        Using doc As New PDFDoc("input.pdf")
            doc.Load("")

            Dim watermark As New Watermark(doc, "Confidential", 
                                           New Font(Font.StandardID.e_StdIDHelvetica), 48.0F, &HFF0000FF)

            Dim settings As New WatermarkSettings()
            settings.flags = Watermark.e_WatermarkFlagASPageContents
            settings.position = Watermark.Position.e_PosCenter
            settings.rotation = -45.0F
            settings.opacity = 0.5F

            watermark.SetSettings(settings)
            watermark.InsertToAllPages()

            doc.SaveAs("output.pdf", PDFDoc.SaveFlags.e_SaveFlagNoOriginal)
        End Using

        Library.Release()
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

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

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("input.pdf");
        pdf.ApplyWatermark(new TextStamper()
        {
            Text = "Confidential",
            FontSize = 48,
            Opacity = 50,
            Rotation = -45,
            VerticalAlignment = VerticalAlignment.Middle,
            HorizontalAlignment = HorizontalAlignment.Center
        });
        pdf.SaveAs("output.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(new TextStamper()
        {
            Text = "Confidential",
            FontSize = 48,
            Opacity = 50,
            Rotation = -45,
            VerticalAlignment = VerticalAlignment.Middle,
            HorizontalAlignment = HorizontalAlignment.Center
        });
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Editing
Imports System

Class Program
    Shared Sub Main()
        Dim pdf = PdfDocument.FromFile("input.pdf")
        pdf.ApplyWatermark(New TextStamper() With {
            .Text = "Confidential",
            .FontSize = 48,
            .Opacity = 50,
            .Rotation = -45,
            .VerticalAlignment = VerticalAlignment.Middle,
            .HorizontalAlignment = HorizontalAlignment.Center
        })
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF's TextStamper provides intuitive property-based configuration instead of separate settings objects and manual page iteration. See the complete watermarking documentation for additional options.

Example 4: URL to PDF with Headers and Footers

Before (Foxit PDF SDK):

using foxit;
using foxit.addon.conversion;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        try
        {
            HTML2PDFSettingData settings = new HTML2PDFSettingData();
            settings.page_width = 595.0f;  // A4
            settings.page_height = 842.0f;
            settings.page_margin_top = 100.0f;
            settings.page_margin_bottom = 100.0f;

            // Foxit PDF SDK has limited header/footer support
            // Often requires post-processing or additional code

            using (HTML2PDF html2pdf = new HTML2PDF(settings))
            {
                html2pdf.ConvertFromURL("https://www.example.com", "webpage.pdf");
            }
        }
        finally
        {
            Library.Release();
        }
    }
}
using foxit;
using foxit.addon.conversion;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        try
        {
            HTML2PDFSettingData settings = new HTML2PDFSettingData();
            settings.page_width = 595.0f;  // A4
            settings.page_height = 842.0f;
            settings.page_margin_top = 100.0f;
            settings.page_margin_bottom = 100.0f;

            // Foxit PDF SDK has limited header/footer support
            // Often requires post-processing or additional code

            using (HTML2PDF html2pdf = new HTML2PDF(settings))
            {
                html2pdf.ConvertFromURL("https://www.example.com", "webpage.pdf");
            }
        }
        finally
        {
            Library.Release();
        }
    }
}
Imports foxit
Imports foxit.addon.conversion

Class Program
    Shared Sub Main()
        Library.Initialize("sn", "key")

        Try
            Dim settings As New HTML2PDFSettingData()
            settings.page_width = 595.0F ' A4
            settings.page_height = 842.0F
            settings.page_margin_top = 100.0F
            settings.page_margin_bottom = 100.0F

            ' Foxit PDF SDK has limited header/footer support
            ' Often requires post-processing or additional code

            Using html2pdf As New HTML2PDF(settings)
                html2pdf.ConvertFromURL("https://www.example.com", "webpage.pdf")
            End Using
        Finally
            Library.Release()
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.PrintHtmlBackgrounds = true;
        renderer.RenderingOptions.WaitFor.RenderDelay(3000);  // Wait for JS

        // Built-in header/footer support
        renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center; font-size:12pt;'>Company Report</div>",
            DrawDividerLine = true
        };

        renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:right; font-size:10pt;'>Page {page} of {total-pages}</div>",
            DrawDividerLine = true
        };

        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.PrintHtmlBackgrounds = true;
        renderer.RenderingOptions.WaitFor.RenderDelay(3000);  // Wait for JS

        // Built-in header/footer support
        renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:center; font-size:12pt;'>Company Report</div>",
            DrawDividerLine = true
        };

        renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
        {
            HtmlFragment = "<div style='text-align:right; font-size:10pt;'>Page {page} of {total-pages}</div>",
            DrawDividerLine = true
        };

        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
        renderer.RenderingOptions.PrintHtmlBackgrounds = True
        renderer.RenderingOptions.WaitFor.RenderDelay(3000) ' Wait for JS

        ' Built-in header/footer support
        renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
            .HtmlFragment = "<div style='text-align:center; font-size:12pt;'>Company Report</div>",
            .DrawDividerLine = True
        }

        renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
            .HtmlFragment = "<div style='text-align:right; font-size:10pt;'>Page {page} of {total-pages}</div>",
            .DrawDividerLine = True
        }

        Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")
        pdf.SaveAs("webpage.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

IronPDF provides native headers and footers support with HTML styling and dynamic page number placeholders.

Example 5: PDF Security and Encryption

Before (Foxit PDF SDK):

using foxit;
using foxit.pdf;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        try
        {
            using (PDFDoc doc = new PDFDoc("input.pdf"))
            {
                doc.LoadW("");

                StdSecurityHandler securityHandler = new StdSecurityHandler();
                securityHandler.Initialize(
                    StdSecurityHandler.EncryptAlgorithm.e_CipherAES,
                    "user_password",
                    "owner_password",
                    PDFDoc.Permission.e_PermPrint | PDFDoc.Permission.e_PermModify,
                    128);

                doc.SetSecurityHandler(securityHandler);
                doc.SaveAs("encrypted.pdf", (int)PDFDoc.SaveFlags.e_SaveFlagNoOriginal);
            }
        }
        finally
        {
            Library.Release();
        }
    }
}
using foxit;
using foxit.pdf;

class Program
{
    static void Main()
    {
        Library.Initialize("sn", "key");

        try
        {
            using (PDFDoc doc = new PDFDoc("input.pdf"))
            {
                doc.LoadW("");

                StdSecurityHandler securityHandler = new StdSecurityHandler();
                securityHandler.Initialize(
                    StdSecurityHandler.EncryptAlgorithm.e_CipherAES,
                    "user_password",
                    "owner_password",
                    PDFDoc.Permission.e_PermPrint | PDFDoc.Permission.e_PermModify,
                    128);

                doc.SetSecurityHandler(securityHandler);
                doc.SaveAs("encrypted.pdf", (int)PDFDoc.SaveFlags.e_SaveFlagNoOriginal);
            }
        }
        finally
        {
            Library.Release();
        }
    }
}
Imports foxit
Imports foxit.pdf

Class Program
    Shared Sub Main()
        Library.Initialize("sn", "key")

        Try
            Using doc As New PDFDoc("input.pdf")
                doc.LoadW("")

                Dim securityHandler As New StdSecurityHandler()
                securityHandler.Initialize(StdSecurityHandler.EncryptAlgorithm.e_CipherAES,
                                           "user_password",
                                           "owner_password",
                                           PDFDoc.Permission.e_PermPrint Or PDFDoc.Permission.e_PermModify,
                                           128)

                doc.SetSecurityHandler(securityHandler)
                doc.SaveAs("encrypted.pdf", CInt(PDFDoc.SaveFlags.e_SaveFlagNoOriginal))
            End Using
        Finally
            Library.Release()
        End Try
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

using IronPdf;

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

        // Set passwords
        pdf.SecuritySettings.OwnerPassword = "owner_password";
        pdf.SecuritySettings.UserPassword = "user_password";

        // Set permissions
        pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
        pdf.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.EditAll;
        pdf.SecuritySettings.AllowUserCopyPasteContent = true;
        pdf.SecuritySettings.AllowUserAnnotations = true;

        pdf.SaveAs("encrypted.pdf");
    }
}
using IronPdf;

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

        // Set passwords
        pdf.SecuritySettings.OwnerPassword = "owner_password";
        pdf.SecuritySettings.UserPassword = "user_password";

        // Set permissions
        pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
        pdf.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.EditAll;
        pdf.SecuritySettings.AllowUserCopyPasteContent = true;
        pdf.SecuritySettings.AllowUserAnnotations = true;

        pdf.SaveAs("encrypted.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim pdf = PdfDocument.FromFile("input.pdf")

        ' Set passwords
        pdf.SecuritySettings.OwnerPassword = "owner_password"
        pdf.SecuritySettings.UserPassword = "user_password"

        ' Set permissions
        pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights
        pdf.SecuritySettings.AllowUserEdits = IronPdf.Security.PdfEditSecurity.EditAll
        pdf.SecuritySettings.AllowUserCopyPasteContent = True
        pdf.SecuritySettings.AllowUserAnnotations = True

        pdf.SaveAs("encrypted.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

Performance Considerations

Reuse ChromePdfRenderer

For optimal performance during your Foxit PDF migration, reuse the ChromePdfRenderer instance—it's thread-safe:

// GOOD - Reuse renderer (thread-safe)
public class PdfService
{
    private static readonly ChromePdfRenderer _renderer = new ChromePdfRenderer();

    public byte[] Generate(string html) => _renderer.RenderHtmlAsPdf(html).BinaryData;
}

// BAD - Creates new instance each time
public byte[] GenerateBad(string html)
{
    var renderer = new ChromePdfRenderer();  // Wasteful
    return renderer.RenderHtmlAsPdf(html).BinaryData;
}
// GOOD - Reuse renderer (thread-safe)
public class PdfService
{
    private static readonly ChromePdfRenderer _renderer = new ChromePdfRenderer();

    public byte[] Generate(string html) => _renderer.RenderHtmlAsPdf(html).BinaryData;
}

// BAD - Creates new instance each time
public byte[] GenerateBad(string html)
{
    var renderer = new ChromePdfRenderer();  // Wasteful
    return renderer.RenderHtmlAsPdf(html).BinaryData;
}
Imports System

Public Class PdfService
    Private Shared ReadOnly _renderer As New ChromePdfRenderer()

    Public Function Generate(html As String) As Byte()
        Return _renderer.RenderHtmlAsPdf(html).BinaryData
    End Function

    ' BAD - Creates new instance each time
    Public Function GenerateBad(html As String) As Byte()
        Dim renderer As New ChromePdfRenderer() ' Wasteful
        Return renderer.RenderHtmlAsPdf(html).BinaryData
    End Function
End Class
$vbLabelText   $csharpLabel

Unit Conversion Helper

Foxit PDF SDK uses points; IronPDF uses millimeters. Use this helper during migration:

public static class UnitConverter
{
    public static double PointsToMm(double points) => points * 0.352778;
    public static double MmToPoints(double mm) => mm / 0.352778;
    public static double InchesToMm(double inches) => inches * 25.4;
}

// Usage: Convert Foxit's 72 points (1 inch) to IronPDF millimeters
renderer.RenderingOptions.MarginTop = UnitConverter.PointsToMm(72); // ~25.4mm
public static class UnitConverter
{
    public static double PointsToMm(double points) => points * 0.352778;
    public static double MmToPoints(double mm) => mm / 0.352778;
    public static double InchesToMm(double inches) => inches * 25.4;
}

// Usage: Convert Foxit's 72 points (1 inch) to IronPDF millimeters
renderer.RenderingOptions.MarginTop = UnitConverter.PointsToMm(72); // ~25.4mm
Public Module UnitConverter
    Public Function PointsToMm(points As Double) As Double
        Return points * 0.352778
    End Function

    Public Function MmToPoints(mm As Double) As Double
        Return mm / 0.352778
    End Function

    Public Function InchesToMm(inches As Double) As Double
        Return inches * 25.4
    End Function
End Module

' Usage: Convert Foxit's 72 points (1 inch) to IronPDF millimeters
renderer.RenderingOptions.MarginTop = UnitConverter.PointsToMm(72) ' ~25.4mm
$vbLabelText   $csharpLabel

Proper Resource Disposal

// GOOD - Using statement for automatic cleanup
using (var pdf = PdfDocument.FromFile("large.pdf"))
{
    string text = pdf.ExtractAllText();
}  // pdf is disposed automatically
// GOOD - Using statement for automatic cleanup
using (var pdf = PdfDocument.FromFile("large.pdf"))
{
    string text = pdf.ExtractAllText();
}  // pdf is disposed automatically
Imports PdfDocument

' GOOD - Using block for automatic cleanup
Using pdf = PdfDocument.FromFile("large.pdf")
    Dim text As String = pdf.ExtractAllText()
End Using ' pdf is disposed automatically
$vbLabelText   $csharpLabel

Troubleshooting

Issue 1: Library.Initialize() Not Found

Problem: Library.Initialize() doesn't exist in IronPDF.

Solution: IronPDF uses a simpler initialization pattern:

// Foxit PDF
Library.Initialize(sn, key);

// IronPDF - just set license key once at startup
IronPdf.License.LicenseKey = "YOUR-KEY";
// Foxit PDF
Library.Initialize(sn, key);

// IronPDF - just set license key once at startup
IronPdf.License.LicenseKey = "YOUR-KEY";
net
$vbLabelText   $csharpLabel

Issue 2: ErrorCode Handling

Problem: Code checks ErrorCode.e_ErrSuccess but IronPDF doesn't have this.

Solution: Use standard .NET exception handling:

// Foxit PDF
ErrorCode err = doc.LoadW("");
if (err != ErrorCode.e_ErrSuccess) { /* handle error */ }

// IronPDF
try
{
    var pdf = PdfDocument.FromFile("input.pdf");
}
catch (IOException ex)
{
    Console.WriteLine($"Failed to load PDF: {ex.Message}");
}
// Foxit PDF
ErrorCode err = doc.LoadW("");
if (err != ErrorCode.e_ErrSuccess) { /* handle error */ }

// IronPDF
try
{
    var pdf = PdfDocument.FromFile("input.pdf");
}
catch (IOException ex)
{
    Console.WriteLine($"Failed to load PDF: {ex.Message}");
}
Imports System
Imports System.IO

' Foxit PDF
Dim err As ErrorCode = doc.LoadW("")
If err <> ErrorCode.e_ErrSuccess Then
    ' handle error
End If

' IronPDF
Try
    Dim pdf = PdfDocument.FromFile("input.pdf")
Catch ex As IOException
    Console.WriteLine($"Failed to load PDF: {ex.Message}")
End Try
$vbLabelText   $csharpLabel

Issue 3: PDFDoc.Close() Not Found

Problem: doc.Close() method doesn't exist in IronPDF.

Solution: Use Dispose() or using statements:

// Foxit PDF
doc.Close();

// IronPDF
pdf.Dispose();
// or better: wrap in using statement
// Foxit PDF
doc.Close();

// IronPDF
pdf.Dispose();
// or better: wrap in using statement
net
$vbLabelText   $csharpLabel

Migration Checklist

Pre-Migration

  • Inventory all Foxit PDF SDK features used
  • Document license key locations
  • Note all Library.Initialize() and Library.Release() calls
  • List custom settings (page sizes, margins, etc.)
  • Identify error handling patterns using ErrorCode
  • Backup project to version control
  • Obtain IronPDF license key

Package Migration

  • Remove Foxit PDF SDK DLL references from .csproj
  • Remove any private NuGet feed configurations
  • Install IronPdf NuGet package: dotnet add package IronPdf
  • Update namespace imports
  • Set IronPDF license key at startup

Code Migration

  • Remove Library.Initialize() and Library.Release() calls
  • Replace ErrorCode checks with try/catch
  • Replace PDFDoc with PdfDocument
  • Replace HTML2PDF with ChromePdfRenderer
  • Update page access from GetPage(i) to Pages[i]
  • Replace SaveAs(path, flags) with SaveAs(path)
  • Replace Close() with Dispose() or using statements
  • Update watermark code to use TextStamper
  • Convert units from points to millimeters

Testing

  • Verify HTML to PDF output matches expectations
  • Test PDF loading and text extraction
  • Verify merge functionality
  • Check watermark appearance
  • Test security/encryption features
  • Validate form field operations
  • Performance testing

Post-Migration

  • Delete Foxit PDF SDK DLLs
  • Remove Foxit-related configuration files
  • Update documentation
  • Clean up unused helper code

migration.

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