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:
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.
Enterprise Pricing: Pricing is tailored for large organizations and can be prohibitive for smaller teams or individual developers.
Manual Installation: Foxit PDF SDK requires manual DLL references or private NuGet feeds—there's no simple public NuGet package available.
Verbose API: Library initialization with
Library.Initialize(), error code checking, and explicitLibrary.Release()calls add substantial boilerplate to every operation.Separate HTML Conversion Add-on: HTML to PDF conversion requires an additional add-on purchase—it's not included in the base SDK.
Complex Configuration: Settings require detailed object configuration (e.g.,
HTML2PDFSettingData) with multiple properties.- C++ Heritage: API patterns reflect C++ origins, feeling less natural in modern C# applications.
Foxit PDF vs IronPDF Comparison
| Aspect | Foxit PDF SDK | IronPDF |
|---|---|---|
| Installation | Manual DLLs/private feeds | Simple NuGet package |
| Licensing | Complex, enterprise-focused | Transparent, suitable for all sizes |
| Initialization | Library.Initialize(sn, key) | Set license key once |
| Error Handling | ErrorCode enums | Standard .NET exceptions |
| HTML to PDF | Separate add-on purchase | Built-in Chromium engine |
| API Style | C++ heritage, verbose | Modern .NET patterns |
| Resource Cleanup | Manual Close()/Release() | IDisposable/automatic |
| Documentation | Enterprise docs portal | Public 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
- .NET Environment: IronPDF supports .NET Framework 4.6.2+, .NET Core 3.1+, .NET 5/6/7/8/9+
- NuGet Access: Ensure you can install packages from NuGet
- 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"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"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 IronPdfIf 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>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;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() neededStep 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");Complete API Reference
Namespace Mapping
| Foxit PDF Namespace | IronPDF Equivalent | Notes |
|---|---|---|
foxit | IronPdf | Main namespace |
foxit.common | IronPdf | Common types |
foxit.common.fxcrt | N/A | Low-level (not needed) |
foxit.pdf | IronPdf | PDF document operations |
foxit.pdf.annots | IronPdf.Editing | Annotations |
foxit.addon.conversion | IronPdf.Rendering | HTML/image conversion |
Core Class Mapping
| Foxit PDF SDK Class | IronPDF Equivalent | Notes |
|---|---|---|
Library | N/A | IronPDF auto-manages |
PDFDoc | PdfDocument | Main document class |
PDFPage | PdfDocument.Pages[i] | Page access |
HTML2PDF | ChromePdfRenderer | HTML conversion |
TextPage | pdf.ExtractTextFromPage(i) | Text extraction |
Watermark | TextStamper / ImageStamper | Watermarks |
Security | SecuritySettings | PDF security |
Form | pdf.Form | Form fields |
Metadata | pdf.MetaData | Document metadata |
PDFDoc Methods
| Foxit PDFDoc | IronPDF PdfDocument | Notes |
|---|---|---|
new PDFDoc(path) | PdfDocument.FromFile(path) | Load from file |
doc.LoadW(password) | PdfDocument.FromFile(path, password) | Password protected |
doc.GetPageCount() | pdf.PageCount | Page 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 statement | Cleanup |
doc.InsertDocument() | PdfDocument.Merge() | Merge documents |
HTML2PDF / Conversion
| Foxit HTML2PDF | IronPDF Equivalent | Notes |
|---|---|---|
new HTML2PDFSettingData() | new ChromePdfRenderer() | Create renderer |
settings.page_width | RenderingOptions.PaperSize | Standard sizes |
settings.page_height | RenderingOptions.SetCustomPaperSize() | Custom size |
html2pdf.Convert(html, path) | renderer.RenderHtmlAsPdf(html) | HTML string |
html2pdf.ConvertFromURL(url, path) | renderer.RenderUrlAsPdf(url) | URL conversion |
Watermark Settings
| Foxit Watermark | IronPDF Equivalent | Notes |
|---|---|---|
new Watermark(doc, text, font, size, color) | new TextStamper() | Text watermark |
WatermarkSettings.position | VerticalAlignment + HorizontalAlignment | Position |
WatermarkSettings.rotation | Rotation | Rotation angle |
WatermarkSettings.opacity | Opacity | 0-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();
}
}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");
}
}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();
}
}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");
}
}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();
}
}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");
}
}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();
}
}
}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");
}
}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();
}
}
}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");
}
}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;
}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.4mmpublic 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.4mmProper 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 automaticallyTroubleshooting
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";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}");
}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 statementMigration Checklist
Pre-Migration
- Inventory all Foxit PDF SDK features used
- Document license key locations
- Note all
Library.Initialize()andLibrary.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()andLibrary.Release()calls - Replace
ErrorCodechecks with try/catch - Replace
PDFDocwithPdfDocument - Replace
HTML2PDFwithChromePdfRenderer - Update page access from
GetPage(i)toPages[i] - Replace
SaveAs(path, flags)withSaveAs(path) - Replace
Close()withDispose()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.






