Skip to footer content
MIGRATION GUIDES

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

  1. 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.

  2. Windows Forms Specific: The library is focused on Windows Forms applications, not offering support for other user interface frameworks.

  3. No PDF Manipulation: Cannot merge, split, or modify PDF content.

  4. Native Binary Dependencies: Requires platform-specific PDFium binaries (x86 and x64 pdfium.dll files).

  5. Uncertain Maintenance: Limited updates and unclear long-term support.

  6. 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.

  7. 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.

  8. No Headers/Footers: Cannot add page numbers or repeating content.

  9. No Watermarks: Cannot stamp documents with overlays.

  10. No Security Features: Cannot encrypt or password-protect PDFs.

PdfiumViewer vs IronPDF Comparison

AspectPdfiumViewerIronPDF
Primary FocusWinForms PDF viewerComplete PDF solution
LicenseApache 2.0Commercial
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 SupportWindows Forms onlyConsole, Web, Desktop
Framework Support.NET Framework.NET Framework, Core, 5+
MaintenanceUncertainActive

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

  1. .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGet Access: Ability to install NuGet packages
  3. 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 IronPdf
SHELL

License 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";
$vbLabelText   $csharpLabel

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" .
SHELL

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;
$vbLabelText   $csharpLabel

Core Class Mappings

PdfiumViewerIronPDFNotes
PdfDocumentPdfDocumentSame name, different capabilities
PdfViewer(no equivalent)IronPDF is backend-focused
PdfRendererChromePdfRendererPDF creation
(not available)HtmlHeaderFooterHeaders/footers

Document Loading Mappings

PdfiumViewerIronPDFNotes
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

PdfiumViewerIronPDFNotes
document.PageCountdocument.PageCountSame
document.PageSizesdocument.Pages[i].Width/HeightPer-page access
document.GetPageSize(index)document.Pages[index].Width/HeightDirect properties

Page Rendering Mappings

PdfiumViewerIronPDFNotes
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

PdfiumViewerIronPDFNotes
document.Save(path)pdf.SaveAs(path)Different method name
document.Save(stream)pdf.StreamAccess stream
(not available)pdf.BinaryDataGet bytes

New Features Not Available in PdfiumViewer

IronPDF FeatureDescription
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.SecuritySettingsPassword protection
pdf.FormForm 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}");
    }
}
$vbLabelText   $csharpLabel

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

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);
}
$vbLabelText   $csharpLabel

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!");
$vbLabelText   $csharpLabel

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);
        }
    }
}
$vbLabelText   $csharpLabel

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

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.dll

After (IronPDF) - Clean Deployment

MyApp/
├── bin/
│   ├── MyApp.dll
│   └── IronPdf.dll  # Everything included

Remove 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" />
SHELL

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 });
$vbLabelText   $csharpLabel

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)
$vbLabelText   $csharpLabel

Save Method Change

// PdfiumViewer
document.Save(path)

// IronPDF
pdf.SaveAs(path)
// PdfiumViewer
document.Save(path)

// IronPDF
pdf.SaveAs(path)
$vbLabelText   $csharpLabel

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");
$vbLabelText   $csharpLabel

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

Feature Comparison Summary

FeaturePdfiumViewerIronPDF
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 SupportLimited
Active MaintenanceUncertain

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 PdfiumViewer NuGet package
  • Remove PdfiumViewer.Native.x86.v8-xfa package
  • Remove PdfiumViewer.Native.x64.v8-xfa package
  • Delete native pdfium.dll binaries from x86/ and x64/ folders
  • Install IronPdf NuGet package: dotnet add package IronPdf

Code Changes

  • Add license key configuration at startup
  • Replace PdfDocument.Load() with PdfDocument.FromFile()
  • Replace document.Save() with pdf.SaveAs()
  • Replace document.Render() with pdf.ToBitmap() or RasterizeToImageFiles()
  • Replace document.PageSizes[i] with pdf.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

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