How to Migrate from Pdfium to IronPDF in C#
Migrating from Pdfium.NET to IronPDF moves your .NET PDF workflow from a rendering-focused library with native binary dependencies to a comprehensive PDF solution that handles creation, manipulation, and rendering without platform-specific complexity. This guide provides a complete, step-by-step migration path that eliminates native dependency management while adding capabilities that Pdfium cannot provide.
Why Migrate from Pdfium to IronPDF
Understanding Pdfium.NET
Pdfium.NET is a .NET wrapper for Google's PDFium library, renowned for its efficiency and speed in rendering PDF documents. It has emerged as a significant library for developers delving into the intricacies of PDF rendering within C# applications, providing high-fidelity replication of PDF content in .NET environments.
However, despite its prowess in rendering, Pdfium.NET's capabilities for creating and manipulating PDF documents are limited. It's mainly built for applications that require displaying PDF content accurately with less emphasis on modifying or creating new PDFs.
Critical Pdfium Limitations
Rendering-Only Focus: Cannot create PDFs from HTML, images, or programmatically. Pdfium's capabilities are restricted to viewing and rendering PDFs.
No PDF Manipulation: Cannot merge, split, or modify PDF content. PDF merging is not natively supported—you would need to use another library like iTextSharp or PdfSharp.
Native Binary Dependencies: Requires platform-specific PDFium binaries. Developers need to manage native PDFium binaries, an aspect that adds complexity during deployment and distribution.
Deployment Complexity: Must bundle and manage native DLLs per platform with x86, x64, and runtimes folders.
Limited Text Extraction: Basic text extraction without formatting. Text extraction requires additional work with Pdfium.NET.
No HTML to PDF: Cannot convert web content to PDF. HTML to PDF conversion is not natively supported in Pdfium.NET.
No Headers/Footers: Cannot add page numbers or repeating content.
No Watermarks: Cannot stamp documents with overlays.
No Form Support: Cannot fill or read PDF forms.
- No Security Features: Cannot encrypt or password-protect PDFs.
Pdfium vs IronPDF Comparison
| Aspect | Pdfium.NET | IronPDF |
|---|---|---|
| Primary Focus | Rendering/viewing | Complete PDF solution |
| Rendering Fidelity | High-fidelity rendering | High, especially for HTML/CSS/JS |
| PDF Creation | ✗ | ✓ (HTML, URL, images) |
| PDF Manipulation | ✗ | ✓ (merge, split, edit) |
| HTML to PDF | ✗ | ✓ (Chromium engine) |
| Watermarks | ✗ | ✓ |
| Headers/Footers | ✗ | ✓ |
| Form Filling | ✗ | ✓ |
| Security | ✗ | ✓ |
| Native Dependencies | Required | None (fully managed) |
| Cross-Platform | Complex setup | Automatic |
| Ease of Deployment | Complicated by native dependencies | Easier; less dependency complication |
For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides a fully managed foundation that eliminates native binary management while adding comprehensive PDF creation and manipulation capabilities.
Before You Start
Prerequisites
- .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
- NuGet Access: Ability to install NuGet packages
- IronPDF License: Obtain your license key from ironpdf.com
NuGet Package Changes
# Remove Pdfium packages
dotnet remove package Pdfium.NET
dotnet remove package Pdfium.Net.SDK
dotnet remove package PdfiumViewer
# Install IronPDF
dotnet add package IronPdf# Remove Pdfium packages
dotnet remove package Pdfium.NET
dotnet remove package Pdfium.Net.SDK
dotnet remove package PdfiumViewer
# Install IronPDF
dotnet add package IronPdfLicense Configuration
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";Identify Pdfium Usage
# Find Pdfium usage
grep -r "Pdfium\|PdfDocument\.Load\|\.Render\(" --include="*.cs" .
# Find native binary references
grep -r "pdfium\.dll\|pdfium\.so\|pdfium\.dylib" --include="*.csproj" --include="*.config" .
# Find platform-specific code
grep -r "#if.*64\|WIN32\|WIN64\|LINUX\|OSX" --include="*.cs" .# Find Pdfium usage
grep -r "Pdfium\|PdfDocument\.Load\|\.Render\(" --include="*.cs" .
# Find native binary references
grep -r "pdfium\.dll\|pdfium\.so\|pdfium\.dylib" --include="*.csproj" --include="*.config" .
# Find platform-specific code
grep -r "#if.*64\|WIN32\|WIN64\|LINUX\|OSX" --include="*.cs" .Complete API Reference
Namespace Changes
// Pdfium.NET
using Pdfium;
using Pdfium.Net;
using PdfiumViewer;
// IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;// Pdfium.NET
using Pdfium;
using Pdfium.Net;
using PdfiumViewer;
// IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;Core Class Mappings
| Pdfium.NET | IronPDF | Notes |
|---|---|---|
PdfDocument | PdfDocument | Same name, different capabilities |
PdfPage | PdfPage | Similar interface |
PdfPageCollection | PdfPageCollection | Similar interface |
| (not available) | ChromePdfRenderer | PDF creation |
| (not available) | HtmlHeaderFooter | Headers/footers |
Document Loading Mappings
| Pdfium.NET | IronPDF | Notes |
|---|---|---|
PdfDocument.Load(path) | PdfDocument.FromFile(path) | Load from file |
PdfDocument.Load(stream) | PdfDocument.FromStream(stream) | Load from stream |
PdfDocument.Load(bytes) | PdfDocument.FromBinaryData(bytes) | Load from bytes |
new PdfDocument(path) | PdfDocument.FromFile(path) | Constructor pattern |
Document Properties Mappings
| Pdfium.NET | IronPDF | Notes |
|---|---|---|
document.PageCount | document.PageCount | Same |
document.Pages | document.Pages | Similar collection |
document.Pages[index] | document.Pages[index] | Zero-based |
document.GetPageSize(index) | document.Pages[index].Width/Height | Direct properties |
Text Extraction Mappings
| Pdfium.NET | IronPDF | Notes |
|---|---|---|
document.GetPdfText(pageIndex) | document.Pages[index].Text | Per-page |
| (manual loop) | document.ExtractAllText() | All pages at once |
page.GetTextBounds() | page.Text | Simplified |
Saving Documents Mappings
| Pdfium.NET | IronPDF | Notes |
|---|---|---|
document.Save(path) | document.SaveAs(path) | Different method name |
document.Save(stream) | document.Stream | Access stream |
| (not available) | document.BinaryData | Get bytes |
Page Rendering Mappings
| Pdfium.NET | IronPDF | Notes |
|---|---|---|
page.Render(width, height) | pdf.RasterizeToImageFiles(path, dpi) | Rasterize |
page.Render(width, height, flags) | DPI parameter | Quality control |
document.Render(index, width, height) | pdf.RasterizeToImageFiles() | Batch render |
page.RenderToScale(scale) | DPI: 72 * scale | Scale to DPI conversion |
New Features Not Available in Pdfium
| IronPDF Feature | Description |
|---|---|
ChromePdfRenderer.RenderHtmlAsPdf() | Create from HTML |
ChromePdfRenderer.RenderUrlAsPdf() | Create from URL |
ChromePdfRenderer.RenderHtmlFileAsPdf() | Create from HTML file |
PdfDocument.Merge() | Combine PDFs |
pdf.CopyPages() | Extract pages |
pdf.RemovePages() | Delete pages |
pdf.InsertPdf() | Insert PDF at position |
pdf.ApplyWatermark() | Add watermarks |
pdf.AddHtmlHeaders() | Add headers |
pdf.AddHtmlFooters() | Add footers |
pdf.SecuritySettings | Password protection |
pdf.SignWithDigitalSignature() | Digital signatures |
pdf.Form | Form filling |
Code Migration Examples
Example 1: Text Extraction from PDF
Before (Pdfium):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Text;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
using (var document = PdfDocument.Load(pdfPath))
{
StringBuilder text = new StringBuilder();
for (int i = 0; i < document.PageCount; i++)
{
// Note: PdfiumViewer has limited text extraction capabilities
// Text extraction requires additional work with Pdfium.NET
string pageText = document.GetPdfText(i);
text.AppendLine(pageText);
}
Console.WriteLine(text.ToString());
}
}
}// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Text;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
using (var document = PdfDocument.Load(pdfPath))
{
StringBuilder text = new StringBuilder();
for (int i = 0; i < document.PageCount; i++)
{
// Note: PdfiumViewer has limited text extraction capabilities
// Text extraction requires additional work with Pdfium.NET
string pageText = document.GetPdfText(i);
text.AppendLine(pageText);
}
Console.WriteLine(text.ToString());
}
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
var pdf = PdfDocument.FromFile(pdfPath);
string text = pdf.ExtractAllText();
Console.WriteLine(text);
}
}// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
string pdfPath = "document.pdf";
var pdf = PdfDocument.FromFile(pdfPath);
string text = pdf.ExtractAllText();
Console.WriteLine(text);
}
}The difference here is significant. Pdfium requires a manual loop through each page with GetPdfText(pageIndex), building a StringBuilder and managing the using statement for proper disposal. The code notes that "PdfiumViewer has limited text extraction capabilities" and "text extraction requires additional work."
IronPDF simplifies this to three lines: load with PdfDocument.FromFile(), extract with ExtractAllText(), and output. The ExtractAllText() method handles all pages automatically with more advanced text extraction capabilities. If you need per-page extraction, you can use pdf.Pages[index].Text. See the text extraction documentation for additional options.
Example 2: PDF Merging
Before (Pdfium):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Collections.Generic;
// Note: PdfiumViewer does not have native PDF merging functionality
// You would need to use additional libraries or implement custom logic
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
// PdfiumViewer is primarily for rendering/viewing
// PDF merging is not natively supported
// You would need to use another library like iTextSharp or PdfSharp
Console.WriteLine("PDF merging not natively supported in PdfiumViewer");
}
}// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.IO;
using System.Collections.Generic;
// Note: PdfiumViewer does not have native PDF merging functionality
// You would need to use additional libraries or implement custom logic
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
// PdfiumViewer is primarily for rendering/viewing
// PDF merging is not natively supported
// You would need to use another library like iTextSharp or PdfSharp
Console.WriteLine("PDF merging not natively supported in PdfiumViewer");
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
var pdf = PdfDocument.Merge(pdfFiles);
pdf.SaveAs("merged.pdf");
Console.WriteLine("PDFs merged successfully");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Collections.Generic;
class Program
{
static void Main()
{
List<string> pdfFiles = new List<string>
{
"document1.pdf",
"document2.pdf",
"document3.pdf"
};
var pdf = PdfDocument.Merge(pdfFiles);
pdf.SaveAs("merged.pdf");
Console.WriteLine("PDFs merged successfully");
}
}This example highlights a fundamental capability gap. Pdfium cannot merge PDFs—the code explicitly states "PDF merging is not natively supported in PdfiumViewer" and "You would need to use another library like iTextSharp or PdfSharp."
IronPDF provides native merging with the static PdfDocument.Merge() method that accepts a list of file paths directly. The result is a new PdfDocument that you save with SaveAs(). Learn more about merging and splitting PDFs.
Example 3: HTML to PDF Conversion
Before (Pdfium):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System.IO;
using System.Drawing.Printing;
// Note: PdfiumViewer is primarily for viewing/rendering PDFs, not creating them from HTML
// For HTML to PDF with Pdfium.NET, you would need additional libraries
// This example shows a limitation of Pdfium.NET
class Program
{
static void Main()
{
// Pdfium.NET does not have native HTML to PDF conversion
// You would need to use a separate library to convert HTML to PDF
// then use Pdfium for manipulation
string htmlContent = "<h1>Hello World</h1>";
// This functionality is not directly available in Pdfium.NET
Console.WriteLine("HTML to PDF conversion not natively supported in Pdfium.NET");
}
}// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System.IO;
using System.Drawing.Printing;
// Note: PdfiumViewer is primarily for viewing/rendering PDFs, not creating them from HTML
// For HTML to PDF with Pdfium.NET, you would need additional libraries
// This example shows a limitation of Pdfium.NET
class Program
{
static void Main()
{
// Pdfium.NET does not have native HTML to PDF conversion
// You would need to use a separate library to convert HTML to PDF
// then use Pdfium for manipulation
string htmlContent = "<h1>Hello World</h1>";
// This functionality is not directly available in Pdfium.NET
Console.WriteLine("HTML to PDF conversion not natively supported in Pdfium.NET");
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string htmlContent = "<h1>Hello World</h1>";
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string htmlContent = "<h1>Hello World</h1>";
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully");
}
}This example demonstrates the most significant capability difference. Pdfium explicitly states "HTML to PDF conversion not natively supported in Pdfium.NET" and "You would need to use a separate library to convert HTML to PDF."
IronPDF provides native HTML to PDF conversion through ChromePdfRenderer, which uses a Chromium engine internally for accurate rendering of HTML, CSS, and JavaScript. The RenderHtmlAsPdf() method converts HTML strings directly to PDF documents. IronPDF can also render URLs with RenderUrlAsPdf() and HTML files with RenderHtmlFileAsPdf(). See the HTML to PDF documentation for comprehensive examples.
Native Dependency Removal
One of the most significant benefits of migrating from Pdfium to IronPDF is eliminating native binary management.
Before (Pdfium) - Complex Deployment
MyApp/
├── bin/
│ ├── MyApp.dll
│ ├── Pdfium.NET.dll
│ ├── x86/
│ │ └── pdfium.dll
│ └── x64/
│ └── pdfium.dll
├── runtimes/
│ ├── win-x86/native/
│ │ └── pdfium.dll
│ └── win-x64/native/
│ └── pdfium.dllAfter (IronPDF) - Clean Deployment
MyApp/
├── bin/
│ ├── MyApp.dll
│ └── IronPdf.dll # Everything includedRemove Native Binary References
# Delete native PDFium binaries
rm -rf x86/ x64/ runtimes/
# Remove from .csproj
# Delete any <Content Include="pdfium.dll" /> entries
# Delete any <None Include="x86/pdfium.dll" /> entries# Delete native PDFium binaries
rm -rf x86/ x64/ runtimes/
# Remove from .csproj
# Delete any <Content Include="pdfium.dll" /> entries
# Delete any <None Include="x86/pdfium.dll" /> entriesCritical Migration Notes
Scale to DPI Conversion
Pdfium uses scale factors; IronPDF uses DPI:
// Formula: IronPDF DPI = 72 × Pdfium scale
// Pdfium scale 2.0 → IronPDF DPI 144
pdf.RasterizeToImageFiles("*.png", DPI: 144);// Formula: IronPDF DPI = 72 × Pdfium scale
// Pdfium scale 2.0 → IronPDF DPI 144
pdf.RasterizeToImageFiles("*.png", DPI: 144);Document Loading Method Change
// Pdfium
PdfDocument.Load(path)
// IronPDF
PdfDocument.FromFile(path)// Pdfium
PdfDocument.Load(path)
// IronPDF
PdfDocument.FromFile(path)Save Method Change
// Pdfium
document.Save(path)
// IronPDF
pdf.SaveAs(path)// Pdfium
document.Save(path)
// IronPDF
pdf.SaveAs(path)Disposal Pattern Simplification
// Pdfium: Required explicit disposal
using (var document = PdfDocument.Load(path))
using (var page = document.Pages[0])
using (var bitmap = page.Render(1024, 768))
{
bitmap.Save("output.png");
}
// IronPDF: Simplified
var pdf = PdfDocument.FromFile(path);
pdf.RasterizeToImageFiles("output.png");// Pdfium: Required explicit disposal
using (var document = PdfDocument.Load(path))
using (var page = document.Pages[0])
using (var bitmap = page.Render(1024, 768))
{
bitmap.Save("output.png");
}
// IronPDF: Simplified
var pdf = PdfDocument.FromFile(path);
pdf.RasterizeToImageFiles("output.png");Platform-Specific Code Removal
// Pdfium: Required platform detection
#if WIN64
// Load x64 pdfium.dll
#else
// Load x86 pdfium.dll
#endif
// IronPDF: Remove all platform-specific code
// Just use the API directly// Pdfium: Required platform detection
#if WIN64
// Load x64 pdfium.dll
#else
// Load x86 pdfium.dll
#endif
// IronPDF: Remove all platform-specific code
// Just use the API directlyFeature Comparison Summary
| Feature | Pdfium.NET | IronPDF |
|---|---|---|
| Load PDF | ✓ | ✓ |
| Render to Image | ✓ | ✓ |
| Extract Text | ✓ (basic) | ✓ (advanced) |
| Page Info | ✓ | ✓ |
| Create from HTML | ✗ | ✓ |
| Create from URL | ✗ | ✓ |
| Merge PDFs | ✗ | ✓ |
| Split PDFs | ✗ | ✓ |
| Add Watermarks | ✗ | ✓ |
| Headers/Footers | ✗ | ✓ |
| Form Filling | ✗ | ✓ |
| Digital Signatures | ✗ | ✓ |
| Password Protection | ✗ | ✓ |
| Native Dependencies | Required | None |
| Cross-Platform | Complex | Automatic |
| Memory Management | Manual disposal | Simplified |
Migration Checklist
Pre-Migration
- Identify all Pdfium usage in codebase
- Document current rendering dimensions/scales used
- List native binary locations in project
- Check for platform-specific loading code
- Identify PDF creation needs (currently using separate tools?)
- Review disposal patterns for conversion
- Obtain IronPDF license key
Package Changes
- Remove
Pdfium.NET,Pdfium.Net.SDK,PdfiumViewerNuGet packages - Delete native pdfium.dll binaries from x86/, x64/, runtimes/ folders
- Remove platform-specific conditional compilation
- Update .csproj to remove native binary references
- Install
IronPdfNuGet package:dotnet add package IronPdf
Code Changes
- Add license key configuration at startup
- Replace
PdfDocument.Load()withPdfDocument.FromFile() - Replace
document.Save()withpdf.SaveAs() - Replace
document.GetPdfText(i)loops withpdf.ExtractAllText() - Convert scale factors to DPI values (DPI = 72 × scale)
- Simplify disposal patterns (remove nested using statements)
- Remove platform-specific code
Post-Migration
- Test rendering output quality
- Compare text extraction results
- Test cross-platform deployment
- Add new capabilities (HTML to PDF, merging, watermarks, security)
- Update documentation






