How to Migrate from PdfiumViewer to IronPDF in C#
Migrating from PdfiumViewer to IronPDF moves your .NET PDF workflow from a Windows Forms viewing-only library with native binary dependencies to a comprehensive PDF solution that handles creation, manipulation, text extraction, and rendering across all .NET application types. This guide provides a complete, step-by-step migration path that eliminates platform restrictions while adding capabilities that PdfiumViewer cannot provide.
Why Migrate from PdfiumViewer to IronPDF
Understanding PdfiumViewer
PdfiumViewer is a .NET wrapper for PDFium, Google's PDF rendering engine used within the Chrome browser. It offers a simple yet potent solution for integrating PDF viewing directly into Windows Forms applications, providing high-performance, high-fidelity PDF rendering capability.
However, it is crucial to remember that PdfiumViewer is solely a viewer. It does not support PDF creation, editing, or manipulation, which may be limiting for applications that demand more than just viewing capabilities. Additionally, its uncertain maintenance status creates risk for production applications—there is some uncertainty regarding its ongoing development and maintenance, which can be a concern for long-term projects.
Critical PdfiumViewer Limitations
Viewing-Only Functionality: Cannot create PDFs from HTML, images, or programmatically. PdfiumViewer's capabilities are limited to viewing PDFs—unlike libraries such as IronPDF, it does not support PDF creation, editing, merging, or other manipulative functions.
Windows Forms Specific: The library is focused on Windows Forms applications, not offering support for other user interface frameworks.
No PDF Manipulation: Cannot merge, split, or modify PDF content.
Native Binary Dependencies: Requires platform-specific PDFium binaries (x86 and x64 pdfium.dll files).
Uncertain Maintenance: Limited updates and unclear long-term support.
No Text Extraction: PdfiumViewer does not have built-in text extraction—you would need to use OCR or another library. It can only render pages as images.
No HTML to PDF: PdfiumViewer is primarily a PDF viewer/renderer, not a generator. It cannot directly convert HTML to PDF. You would need to use another library like wkhtmltopdf or similar.
No Headers/Footers: Cannot add page numbers or repeating content.
No Watermarks: Cannot stamp documents with overlays.
- No Security Features: Cannot encrypt or password-protect PDFs.
PdfiumViewer vs IronPDF Comparison
| Aspect | PdfiumViewer | IronPDF |
|---|---|---|
| Primary Focus | WinForms PDF viewer | Complete PDF solution |
| License | Apache 2.0 | Commercial |
| PDF Creation | ✗ | ✓ (HTML, URL, images) |
| PDF Manipulation | ✗ | ✓ (merge, split, edit) |
| HTML to PDF | ✗ | ✓ (Chromium engine) |
| Text Extraction | ✗ | ✓ |
| Watermarks | ✗ | ✓ |
| Headers/Footers | ✗ | ✓ |
| Security | ✗ | ✓ |
| Built-in Viewer | ✓ | ✗ (backend-focused) |
| Platform Support | Windows Forms only | Console, Web, Desktop |
| Framework Support | .NET Framework | .NET Framework, Core, 5+ |
| Maintenance | Uncertain | Active |
For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides a comprehensive, actively maintained foundation that works across all .NET application types, eliminating the Windows Forms restriction and native binary complexity.
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 PdfiumViewer packages
dotnet remove package PdfiumViewer
dotnet remove package PdfiumViewer.Native.x86.v8-xfa
dotnet remove package PdfiumViewer.Native.x64.v8-xfa
# Install IronPDF
dotnet add package IronPdf# Remove PdfiumViewer packages
dotnet remove package PdfiumViewer
dotnet remove package PdfiumViewer.Native.x86.v8-xfa
dotnet remove package PdfiumViewer.Native.x64.v8-xfa
# 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 PdfiumViewer Usage
# Find PdfiumViewer usage
grep -r "PdfiumViewer\|PdfViewer\|PdfDocument\.Load" --include="*.cs" .
# Find native binary references
grep -r "pdfium\.dll\|Native\.x86\|Native\.x64" --include="*.csproj" .
# Find viewer control usage
grep -r "PdfViewer" --include="*.cs" --include="*.Designer.cs" .# Find PdfiumViewer usage
grep -r "PdfiumViewer\|PdfViewer\|PdfDocument\.Load" --include="*.cs" .
# Find native binary references
grep -r "pdfium\.dll\|Native\.x86\|Native\.x64" --include="*.csproj" .
# Find viewer control usage
grep -r "PdfViewer" --include="*.cs" --include="*.Designer.cs" .Complete API Reference
Namespace Changes
// PdfiumViewer
using PdfiumViewer;
// IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;// PdfiumViewer
using PdfiumViewer;
// IronPDF
using IronPdf;
using IronPdf.Rendering;
using IronPdf.Editing;Core Class Mappings
| PdfiumViewer | IronPDF | Notes |
|---|---|---|
PdfDocument | PdfDocument | Same name, different capabilities |
PdfViewer | (no equivalent) | IronPDF is backend-focused |
PdfRenderer | ChromePdfRenderer | PDF creation |
| (not available) | HtmlHeaderFooter | Headers/footers |
Document Loading Mappings
| PdfiumViewer | 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 |
Document Properties Mappings
| PdfiumViewer | IronPDF | Notes |
|---|---|---|
document.PageCount | document.PageCount | Same |
document.PageSizes | document.Pages[i].Width/Height | Per-page access |
document.GetPageSize(index) | document.Pages[index].Width/Height | Direct properties |
Page Rendering Mappings
| PdfiumViewer | IronPDF | Notes |
|---|---|---|
document.Render(pageIndex, dpiX, dpiY, forPrinting) | pdf.ToBitmap(pageIndex) | Returns bitmap array |
document.Render(pageIndex, width, height, dpiX, dpiY, flags) | pdf.RasterizeToImageFiles(path, dpi) | Batch render |
Saving Documents Mappings
| PdfiumViewer | IronPDF | Notes |
|---|---|---|
document.Save(path) | pdf.SaveAs(path) | Different method name |
document.Save(stream) | pdf.Stream | Access stream |
| (not available) | pdf.BinaryData | Get bytes |
New Features Not Available in PdfiumViewer
| IronPDF Feature | Description |
|---|---|
pdf.ExtractAllText() | Extract text from all pages |
pdf.ExtractTextFromPage(index) | Extract text from specific page |
ChromePdfRenderer.RenderHtmlAsPdf() | Create from HTML |
ChromePdfRenderer.RenderUrlAsPdf() | Create from URL |
PdfDocument.Merge() | Combine PDFs |
pdf.CopyPages() | Extract pages |
pdf.RemovePages() | Delete pages |
pdf.ApplyWatermark() | Add watermarks |
pdf.AddHtmlHeaders() | Add headers |
pdf.AddHtmlFooters() | Add footers |
pdf.SecuritySettings | Password protection |
pdf.Form | Form filling |
Code Migration Examples
Example 1: Text Extraction from PDF
Before (PdfiumViewer):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.Text;
string pdfPath = "document.pdf";
// PDFiumViewer has limited text extraction capabilities
// It's primarily designed for rendering, not text extraction
using (var document = PdfDocument.Load(pdfPath))
{
int pageCount = document.PageCount;
Console.WriteLine($"Total pages: {pageCount}");
// PDFiumViewer does not have built-in text extraction
// You would need to use OCR or another library
// It can only render pages as images
for (int i = 0; i < pageCount; i++)
{
var pageImage = document.Render(i, 96, 96, false);
Console.WriteLine($"Rendered page {i + 1}");
}
}// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.Text;
string pdfPath = "document.pdf";
// PDFiumViewer has limited text extraction capabilities
// It's primarily designed for rendering, not text extraction
using (var document = PdfDocument.Load(pdfPath))
{
int pageCount = document.PageCount;
Console.WriteLine($"Total pages: {pageCount}");
// PDFiumViewer does not have built-in text extraction
// You would need to use OCR or another library
// It can only render pages as images
for (int i = 0; i < pageCount; i++)
{
var pageImage = document.Render(i, 96, 96, false);
Console.WriteLine($"Rendered page {i + 1}");
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
string pdfPath = "document.pdf";
// Open and extract text from PDF
PdfDocument pdf = PdfDocument.FromFile(pdfPath);
// Extract text from all pages
string allText = pdf.ExtractAllText();
Console.WriteLine("Extracted Text:");
Console.WriteLine(allText);
// Extract text from specific page
string pageText = pdf.ExtractTextFromPage(0);
Console.WriteLine($"\nFirst page text: {pageText}");
Console.WriteLine($"\nTotal pages: {pdf.PageCount}");// NuGet: Install-Package IronPdf
using IronPdf;
using System;
string pdfPath = "document.pdf";
// Open and extract text from PDF
PdfDocument pdf = PdfDocument.FromFile(pdfPath);
// Extract text from all pages
string allText = pdf.ExtractAllText();
Console.WriteLine("Extracted Text:");
Console.WriteLine(allText);
// Extract text from specific page
string pageText = pdf.ExtractTextFromPage(0);
Console.WriteLine($"\nFirst page text: {pageText}");
Console.WriteLine($"\nTotal pages: {pdf.PageCount}");This example highlights a fundamental capability gap. PdfiumViewer explicitly states it "does not have built-in text extraction" and "you would need to use OCR or another library"—it can only render pages as images. If you need text from a PDF with PdfiumViewer, you're forced to render to an image and run OCR.
IronPDF provides native text extraction with ExtractAllText() for the entire document or ExtractTextFromPage(index) for specific pages. No OCR, no workarounds—direct text extraction from the PDF content. See the text extraction documentation for additional options.
Example 2: HTML to PDF Conversion
Before (PdfiumViewer):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System.IO;
using System.Drawing.Printing;
// PDFiumViewer is primarily a PDF viewer/renderer, not a generator
// It cannot directly convert HTML to PDF
// You would need to use another library to first create the PDF
// Then use PDFiumViewer to display it:
string htmlContent = "<h1>Hello World</h1><p>This is a test document.</p>";
// This functionality is NOT available in PDFiumViewer
// You would need a different library like wkhtmltopdf or similar
// PDFiumViewer can only open and display existing PDFs:
string existingPdfPath = "output.pdf";
using (var document = PdfDocument.Load(existingPdfPath))
{
// Can only render/display existing PDF
var image = document.Render(0, 300, 300, true);
}// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System.IO;
using System.Drawing.Printing;
// PDFiumViewer is primarily a PDF viewer/renderer, not a generator
// It cannot directly convert HTML to PDF
// You would need to use another library to first create the PDF
// Then use PDFiumViewer to display it:
string htmlContent = "<h1>Hello World</h1><p>This is a test document.</p>";
// This functionality is NOT available in PDFiumViewer
// You would need a different library like wkhtmltopdf or similar
// PDFiumViewer can only open and display existing PDFs:
string existingPdfPath = "output.pdf";
using (var document = PdfDocument.Load(existingPdfPath))
{
// Can only render/display existing PDF
var image = document.Render(0, 300, 300, true);
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
string htmlContent = "<h1>Hello World</h1><p>This is a test document.</p>";
// Create a PDF from HTML string
var renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully!");// NuGet: Install-Package IronPdf
using IronPdf;
using System;
string htmlContent = "<h1>Hello World</h1><p>This is a test document.</p>";
// Create a PDF from HTML string
var renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF
pdf.SaveAs("output.pdf");
Console.WriteLine("PDF created successfully!");This example demonstrates the most significant capability difference between the two libraries. PdfiumViewer explicitly states "This functionality is NOT available in PDFiumViewer" and "You would need a different library like wkhtmltopdf or similar"—PdfiumViewer can only open and display existing PDFs.
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.
Example 3: PDF to Image Conversion
Before (PdfiumViewer):
// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.Drawing;
using System.Drawing.Imaging;
string pdfPath = "document.pdf";
string outputImage = "page1.png";
// PDFiumViewer excels at rendering PDFs to images
using (var document = PdfDocument.Load(pdfPath))
{
// Render first page at 300 DPI
int dpi = 300;
using (var image = document.Render(0, dpi, dpi, true))
{
// Save as PNG
image.Save(outputImage, ImageFormat.Png);
Console.WriteLine($"Page rendered to {outputImage}");
}
// Render all pages
for (int i = 0; i < document.PageCount; i++)
{
using (var pageImage = document.Render(i, 150, 150, true))
{
pageImage.Save($"page_{i + 1}.png", ImageFormat.Png);
}
}
}// NuGet: Install-Package PdfiumViewer
using PdfiumViewer;
using System;
using System.Drawing;
using System.Drawing.Imaging;
string pdfPath = "document.pdf";
string outputImage = "page1.png";
// PDFiumViewer excels at rendering PDFs to images
using (var document = PdfDocument.Load(pdfPath))
{
// Render first page at 300 DPI
int dpi = 300;
using (var image = document.Render(0, dpi, dpi, true))
{
// Save as PNG
image.Save(outputImage, ImageFormat.Png);
Console.WriteLine($"Page rendered to {outputImage}");
}
// Render all pages
for (int i = 0; i < document.PageCount; i++)
{
using (var pageImage = document.Render(i, 150, 150, true))
{
pageImage.Save($"page_{i + 1}.png", ImageFormat.Png);
}
}
}After (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Linq;
string pdfPath = "document.pdf";
string outputImage = "page1.png";
// Open PDF and convert to images
PdfDocument pdf = PdfDocument.FromFile(pdfPath);
// Convert first page to image
var firstPageImage = pdf.ToBitmap(0);
firstPageImage[0].Save(outputImage);
Console.WriteLine($"Page rendered to {outputImage}");
// Convert all pages to images
var allPageImages = pdf.ToBitmap();
for (int i = 0; i < allPageImages.Length; i++)
{
allPageImages[i].Save($"page_{i + 1}.png");
Console.WriteLine($"Saved page {i + 1}");
}
Console.WriteLine($"Total pages converted: {pdf.PageCount}");// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Linq;
string pdfPath = "document.pdf";
string outputImage = "page1.png";
// Open PDF and convert to images
PdfDocument pdf = PdfDocument.FromFile(pdfPath);
// Convert first page to image
var firstPageImage = pdf.ToBitmap(0);
firstPageImage[0].Save(outputImage);
Console.WriteLine($"Page rendered to {outputImage}");
// Convert all pages to images
var allPageImages = pdf.ToBitmap();
for (int i = 0; i < allPageImages.Length; i++)
{
allPageImages[i].Save($"page_{i + 1}.png");
Console.WriteLine($"Saved page {i + 1}");
}
Console.WriteLine($"Total pages converted: {pdf.PageCount}");This is one area where PdfiumViewer excels—PDF rendering to images is its primary strength. Both libraries handle this task effectively, but with different patterns.
PdfiumViewer uses document.Render(pageIndex, dpiX, dpiY, forPrinting) with nested using statements for proper disposal. You need to import System.Drawing and System.Drawing.Imaging for the ImageFormat enum.
IronPDF uses pdf.ToBitmap(pageIndex) which returns a bitmap array. The pattern is simpler without nested disposal requirements. For batch operations, ToBitmap() without parameters returns all pages. You can also use RasterizeToImageFiles() for direct file output. See the PDF to image documentation for additional rendering options.
Native Dependency Removal
One of the significant benefits of migrating from PdfiumViewer to IronPDF is eliminating native binary management.
Before (PdfiumViewer) - Complex Deployment
MyApp/
├── bin/
│ ├── MyApp.dll
│ ├── PdfiumViewer.dll
│ ├── x86/
│ │ └── pdfium.dll
│ └── x64/
│ └── 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 native package references
# <PackageReference Include="PdfiumViewer.Native.x86.v8-xfa" />
# <PackageReference Include="PdfiumViewer.Native.x64.v8-xfa" /># Delete native PDFium binaries
rm -rf x86/ x64/ runtimes/
# Remove from .csproj native package references
# <PackageReference Include="PdfiumViewer.Native.x86.v8-xfa" />
# <PackageReference Include="PdfiumViewer.Native.x64.v8-xfa" />Critical Migration Notes
No Built-in Viewer Control
IronPDF is backend-focused and does not include a visual PDF viewer control:
// PdfiumViewer: Built-in viewer control
pdfViewer.Document = document;
// IronPDF: Use external viewer or web-based approach
pdf.SaveAs(tempPath);
Process.Start(new ProcessStartInfo(tempPath) { UseShellExecute = true });// PdfiumViewer: Built-in viewer control
pdfViewer.Document = document;
// IronPDF: Use external viewer or web-based approach
pdf.SaveAs(tempPath);
Process.Start(new ProcessStartInfo(tempPath) { UseShellExecute = true });For viewing needs, consider using Process.Start() to open in the default PDF viewer, a WebBrowser control with the PDF path, or third-party viewer controls like Syncfusion, DevExpress, or Telerik.
Document Loading Method Change
// PdfiumViewer
PdfDocument.Load(path)
// IronPDF
PdfDocument.FromFile(path)// PdfiumViewer
PdfDocument.Load(path)
// IronPDF
PdfDocument.FromFile(path)Save Method Change
// PdfiumViewer
document.Save(path)
// IronPDF
pdf.SaveAs(path)// PdfiumViewer
document.Save(path)
// IronPDF
pdf.SaveAs(path)Render Method Change
// PdfiumViewer: Returns image with nested using
using (var image = document.Render(0, 150, 150, true))
{
image.Save("page.png", ImageFormat.Png);
}
// IronPDF: Returns bitmap array
var images = pdf.ToBitmap(0);
images[0].Save("page.png");// PdfiumViewer: Returns image with nested using
using (var image = document.Render(0, 150, 150, true))
{
image.Save("page.png", ImageFormat.Png);
}
// IronPDF: Returns bitmap array
var images = pdf.ToBitmap(0);
images[0].Save("page.png");Page Size Access Change
// PdfiumViewer
var size = document.PageSizes[index];
Console.WriteLine($"{size.Width} x {size.Height}");
// IronPDF
var page = pdf.Pages[index];
Console.WriteLine($"{page.Width} x {page.Height}");// PdfiumViewer
var size = document.PageSizes[index];
Console.WriteLine($"{size.Width} x {size.Height}");
// IronPDF
var page = pdf.Pages[index];
Console.WriteLine($"{page.Width} x {page.Height}");Feature Comparison Summary
| Feature | PdfiumViewer | IronPDF |
|---|---|---|
| Load PDF | ✓ | ✓ |
| Render to Image | ✓ | ✓ |
| Built-in Viewer | ✓ | ✗ |
| Print PDF | ✓ | ✓ |
| Extract Text | ✗ | ✓ |
| Create from HTML | ✗ | ✓ |
| Create from URL | ✗ | ✓ |
| Merge PDFs | ✗ | ✓ |
| Split PDFs | ✗ | ✓ |
| Add Watermarks | ✗ | ✓ |
| Headers/Footers | ✗ | ✓ |
| Form Filling | ✗ | ✓ |
| Password Protection | ✗ | ✓ |
| WinForms Support | ✓ | ✓ |
| ASP.NET Support | ✗ | ✓ |
| .NET Core Support | Limited | ✓ |
| Active Maintenance | Uncertain | ✓ |
Migration Checklist
Pre-Migration
- Identify all PdfiumViewer usage in codebase
- List WinForms using PdfViewer control
- Document current rendering DPI settings
- Check for native binary references
- Identify print functionality usage
- Plan viewer control replacement strategy
- Obtain IronPDF license key
Package Changes
- Remove
PdfiumViewerNuGet package - Remove
PdfiumViewer.Native.x86.v8-xfapackage - Remove
PdfiumViewer.Native.x64.v8-xfapackage - Delete native pdfium.dll binaries from x86/ and x64/ folders
- 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.Render()withpdf.ToBitmap()orRasterizeToImageFiles() - Replace
document.PageSizes[i]withpdf.Pages[i].Width/Height - Replace PdfViewer control with external viewer or Process.Start()
- Add new capabilities (text extraction, HTML to PDF, etc.)
Post-Migration
- Test rendering output quality
- Test printing functionality
- Test on target platforms
- Add new features (HTML to PDF, merging, watermarks, security)
- Update documentation






