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:

<!-- Remove these manually -->
<Reference Include="fsdk_dotnet">
    <HintPath>..\libs\Foxit\fsdk_dotnet.dll</HintPath>
</Reference>
<!-- Remove these manually -->
<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;
$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
$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");
$vbLabelText   $csharpLabel

Complete API Reference

Namespace Mapping

Foxit PDF NamespaceIronPDF EquivalentNotes
foxitIronPdfMain namespace
foxit.commonIronPdfCommon types
foxit.common.fxcrtN/ALow-level (not needed)
foxit.pdfIronPdfPDF document operations
foxit.pdf.annotsIronPdf.EditingAnnotations
foxit.addon.conversionIronPdf.RenderingHTML/image conversion

Core Class Mapping

Foxit PDF SDK ClassIronPDF EquivalentNotes
LibraryN/AIronPDF auto-manages
PDFDocPdfDocumentMain document class
PDFPagePdfDocument.Pages[i]Page access
HTML2PDFChromePdfRendererHTML conversion
TextPagepdf.ExtractTextFromPage(i)Text extraction
WatermarkTextStamper / ImageStamperWatermarks
SecuritySecuritySettingsPDF security
Formpdf.FormForm fields
Metadatapdf.MetaDataDocument metadata

PDFDoc Methods

Foxit PDFDocIronPDF PdfDocumentNotes
new PDFDoc(path)PdfDocument.FromFile(path)Load from file
doc.LoadW(password)PdfDocument.FromFile(path, password)Password protected
doc.GetPageCount()pdf.PageCountPage count property
doc.GetPage(index)pdf.Pages[index]Get page by index
doc.SaveAs(path, flags)pdf.SaveAs(path)Save document
doc.Close()pdf.Dispose() or using statementCleanup
doc.InsertDocument()PdfDocument.Merge()Merge documents

HTML2PDF / Conversion

Foxit HTML2PDFIronPDF EquivalentNotes
new HTML2PDFSettingData()new ChromePdfRenderer()Create renderer
settings.page_widthRenderingOptions.PaperSizeStandard sizes
settings.page_heightRenderingOptions.SetCustomPaperSize()Custom size
html2pdf.Convert(html, path)renderer.RenderHtmlAsPdf(html)HTML string
html2pdf.ConvertFromURL(url, path)renderer.RenderUrlAsPdf(url)URL conversion

Watermark Settings

Foxit WatermarkIronPDF EquivalentNotes
new Watermark(doc, text, font, size, color)new TextStamper()Text watermark
WatermarkSettings.positionVerticalAlignment + HorizontalAlignmentPosition
WatermarkSettings.rotationRotationRotation angle
WatermarkSettings.opacityOpacity0-100 percentage
watermark.InsertToAllPages()pdf.ApplyStamp(stamper)Apply to all

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();
    }
}
$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");
    }
}
$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();
    }
}
$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");
    }
}
$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();
    }
}
$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");
    }
}
$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();
        }
    }
}
$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");
    }
}
$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();
        }
    }
}
$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");
    }
}
$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;
}
$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
$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
$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";
$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}");
}
$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
$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