푸터 콘텐츠로 바로가기
MIGRATION GUIDES

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

  1. Rendering-Only Focus: Cannot create PDFs from HTML, images, or programmatically. Pdfium's capabilities are restricted to viewing and rendering PDFs.

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

  3. Native Binary Dependencies: Requires platform-specific PDFium binaries. Developers need to manage native PDFium binaries, an aspect that adds complexity during deployment and distribution.

  4. Deployment Complexity: Must bundle and manage native DLLs per platform with x86, x64, and runtimes folders.

  5. Limited Text Extraction: Basic text extraction without formatting. Text extraction requires additional work with Pdfium.NET.

  6. No HTML to PDF: Cannot convert web content to PDF. HTML to PDF conversion is not natively supported in Pdfium.NET.

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

  8. No Watermarks: Cannot stamp documents with overlays.

  9. No Form Support: Cannot fill or read PDF forms.

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

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

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

Core Class Mappings

Pdfium.NET IronPDF
PdfDocument PdfDocument
PdfPage PdfPage
PdfPageCollection PdfPageCollection
(not available) ChromePdfRenderer
(not available) HtmlHeaderFooter

Document Loading Mappings

Pdfium.NET IronPDF
PdfDocument.Load(path) PdfDocument.FromFile(path)
PdfDocument.Load(stream) PdfDocument.FromStream(stream)
PdfDocument.Load(bytes) PdfDocument.FromBinaryData(bytes)
new PdfDocument(path) PdfDocument.FromFile(path)

Document Properties Mappings

Pdfium.NET IronPDF
document.PageCount document.PageCount
document.Pages document.Pages
document.Pages[index] document.Pages[index]
document.GetPageSize(index) document.Pages[index].Width/Height

Text Extraction Mappings

Pdfium.NET IronPDF
document.GetPdfText(pageIndex) document.Pages[index].Text
(manual loop) document.ExtractAllText()
page.GetTextBounds() page.Text

Saving Documents Mappings

Pdfium.NET IronPDF
document.Save(path) document.SaveAs(path)
document.Save(stream) document.Stream
(not available) document.BinaryData

Page Rendering Mappings

Pdfium.NET IronPDF
page.Render(width, height) pdf.RasterizeToImageFiles(path, dpi)
page.Render(width, height, flags) DPI parameter
document.Render(index, width, height) pdf.RasterizeToImageFiles()
page.RenderToScale(scale) DPI: 72 * scale

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

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

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

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

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

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

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.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
# 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" /> entries
SHELL

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

Document Loading Method Change

// Pdfium
PdfDocument.Load(path)

// IronPDF
PdfDocument.FromFile(path)
// Pdfium
PdfDocument.Load(path)

// IronPDF
PdfDocument.FromFile(path)
$vbLabelText   $csharpLabel

Save Method Change

// Pdfium
document.Save(path)

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

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

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

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

Feature 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, PdfiumViewer NuGet packages
  • Delete native pdfium.dll binaries from x86/, x64/, runtimes/ folders
  • Remove platform-specific conditional compilation
  • Update .csproj to remove native binary references
  • 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.GetPdfText(i) loops with pdf.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

커티스 차우
기술 문서 작성자

커티스 차우는 칼턴 대학교에서 컴퓨터 과학 학사 학위를 취득했으며, Node.js, TypeScript, JavaScript, React를 전문으로 하는 프론트엔드 개발자입니다. 직관적이고 미적으로 뛰어난 사용자 인터페이스를 만드는 데 열정을 가진 그는 최신 프레임워크를 활용하고, 잘 구성되고 시각적으로 매력적인 매뉴얼을 제작하는 것을 즐깁니다.

커티스는 개발 분야 외에도 사물 인터넷(IoT)에 깊은 관심을 가지고 있으며, 하드웨어와 소프트웨어를 통합하는 혁신적인 방법을 연구합니다. 여가 시간에는 게임을 즐기거나 디스코드 봇을 만들면서 기술에 대한 애정과 창의성을 결합합니다.