Skip to footer content
MIGRATION GUIDES

How to Migrate from PDFView4NET to IronPDF in C#

Migrating from PDFView4NET to IronPDF transforms your PDF workflow from a UI-focused viewing component to a comprehensive PDF generation and manipulation library. This guide provides a complete, step-by-step migration path that enables server-side processing, web application support, and full PDF lifecycle management capabilities that PDFView4NET cannot provide.

Why Migrate from PDFView4NET to IronPDF

Understanding PDFView4NET

PDFView4NET is a popular choice for developers focusing primarily on PDF viewing features in C#. PDFView4NET provides robust PDF viewing controls tailored for Windows Forms (WinForms) and Windows Presentation Foundation (WPF) applications. The library's emphasis on providing a seamless PDF viewing experience makes it a go-to option for desktop application development.

Despite its strengths, PDFView4NET has limitations that may prompt developers to explore more comprehensive libraries like IronPDF, which offers an all-in-one PDF solution encompassing creation, viewing, and manipulation capabilities without being constrained to specific UI components.

The View-Only Limitation

PDFView4NET is primarily a UI viewing component for WinForms and WPF applications. It focuses on displaying PDFs rather than creating or manipulating them. Key reasons to migrate:

  1. View-Only Limitations: PDFView4NET is designed for viewing, not PDF creation.

  2. UI Framework Dependency: Requires WinForms or WPF context. The requirement for WinForms or WPF environments can restrict usage in other contexts, such as console applications or web services, which are unsupported by PDFView4NET.

  3. No HTML to PDF: Cannot convert HTML or URLs to PDF. The library strictly focuses on viewing, with no built-in capabilities for creating or manipulating PDF files.

  4. Limited Manipulation: Basic editing compared to IronPDF's full feature set.

  5. No Server-Side Support: Cannot run in web services or Azure Functions.

  6. Legacy Technology: Less active development and modern feature updates.

PDFView4NET vs IronPDF Comparison

FeaturePDFView4NETIronPDF
Primary FocusPDF ViewingComplete PDF Solution (Create, View, Edit)
UI Frameworks RequiredWinForms, WPFNone
PDF CreationNoYes
PDF ManipulationLimited (Annotations)Yes
Server-SideNot SupportedFull Support
Web ApplicationsNoYes
Console AppsLimitedFull Support
Azure/DockerNoYes
HTML to PDFNoYes
Cross-Platform ContextNoYes
Ease of IntegrationMediumHigh

IronPDF sets itself apart with its versatility and comprehensive feature set, making it particularly appealing for developers needing a holistic approach to PDF handling in C#. The library supports PDF creation, viewing, editing, and more, addressing use cases that extend far beyond the viewing capabilities of PDFView4NET.

For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides context independence—it can be used across different contexts, including web applications, services, and console applications. This flexibility is crucial for projects requiring cross-platform support and diverse deployment scenarios.


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 PDFView4NET -->
<PackageReference Include="O2S.Components.PDFView4NET" Version="*" Remove />

<!-- Add IronPDF -->
<PackageReference Include="IronPdf" Version="2024.*" />
<!-- Remove PDFView4NET -->
<PackageReference Include="O2S.Components.PDFView4NET" Version="*" Remove />

<!-- Add IronPDF -->
<PackageReference Include="IronPdf" Version="2024.*" />
XML

Or via CLI:

dotnet remove package O2S.Components.PDFView4NET
dotnet add package IronPdf
dotnet remove package O2S.Components.PDFView4NET
dotnet add package IronPdf
SHELL

License Configuration

// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
$vbLabelText   $csharpLabel

Complete API Reference

Namespace Changes

// Before: PDFView4NET
using O2S.Components.PDFView4NET;
using O2S.Components.PDFView4NET.HtmlToPdf;
using O2S.Components.PDFView4NET.Printing;

// After: IronPDF
using IronPdf;
// Before: PDFView4NET
using O2S.Components.PDFView4NET;
using O2S.Components.PDFView4NET.HtmlToPdf;
using O2S.Components.PDFView4NET.Printing;

// After: IronPDF
using IronPdf;
$vbLabelText   $csharpLabel

Core API Mappings

PDFView4NETIronPDFNotes
PDFFile.Open(path)PdfDocument.FromFile(path)Load PDF
PDFFile.Open(stream)PdfDocument.FromStream(stream)Load from stream
pdfFile.GetPage(index)pdf.Pages[index]Access page
pdfFile.PageCountpdf.PageCountPage count
PDFPrintDocumentpdf.Print()Print PDF
pdfFile.Close()pdf.Dispose()Cleanup
HtmlToPdfConverterChromePdfRendererHTML to PDF
N/APdfDocument.Merge()Merge PDFs
N/Apdf.ApplyWatermark()Add watermark
N/Apdf.SecuritySettingsPassword protection

Code Migration Examples

Example 1: URL to PDF Conversion

Before (PDFView4NET):

// NuGet: Install-Package O2S.Components.PDFView4NET
using O2S.Components.PDFView4NET;
using O2S.Components.PDFView4NET.HtmlToPdf;
using System;

class Program
{
    static void Main()
    {
        HtmlToPdfConverter converter = new HtmlToPdfConverter();
        converter.NavigateUri = new Uri("https://example.com");
        converter.ConvertHtmlToPdf();
        converter.SavePdf("output.pdf");
    }
}
// NuGet: Install-Package O2S.Components.PDFView4NET
using O2S.Components.PDFView4NET;
using O2S.Components.PDFView4NET.HtmlToPdf;
using System;

class Program
{
    static void Main()
    {
        HtmlToPdfConverter converter = new HtmlToPdfConverter();
        converter.NavigateUri = new Uri("https://example.com");
        converter.ConvertHtmlToPdf();
        converter.SavePdf("output.pdf");
    }
}
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://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://example.com");
        pdf.SaveAs("output.pdf");
    }
}
$vbLabelText   $csharpLabel

PDFView4NET uses HtmlToPdfConverter with NavigateUri property set to a Uri object, followed by calling ConvertHtmlToPdf() and then SavePdf(). IronPDF simplifies this to a single ChromePdfRenderer with RenderUrlAsPdf() that accepts a string URL directly, returning a PdfDocument that you save with SaveAs(). IronPDF's approach offers cleaner syntax and better integration with modern .NET applications. See the HTML to PDF documentation for comprehensive examples.

Example 2: HTML String to PDF Conversion

Before (PDFView4NET):

// NuGet: Install-Package O2S.Components.PDFView4NET
using O2S.Components.PDFView4NET;
using O2S.Components.PDFView4NET.HtmlToPdf;
using System;

class Program
{
    static void Main()
    {
        string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        HtmlToPdfConverter converter = new HtmlToPdfConverter();
        converter.HtmlContent = htmlContent;
        converter.ConvertHtmlToPdf();
        converter.SavePdf("document.pdf");
    }
}
// NuGet: Install-Package O2S.Components.PDFView4NET
using O2S.Components.PDFView4NET;
using O2S.Components.PDFView4NET.HtmlToPdf;
using System;

class Program
{
    static void Main()
    {
        string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        HtmlToPdfConverter converter = new HtmlToPdfConverter();
        converter.HtmlContent = htmlContent;
        converter.ConvertHtmlToPdf();
        converter.SavePdf("document.pdf");
    }
}
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("document.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        string htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("document.pdf");
    }
}
$vbLabelText   $csharpLabel

PDFView4NET uses the HtmlContent property to set the HTML string, then requires calling ConvertHtmlToPdf() followed by SavePdf(). IronPDF provides a more fluent API where RenderHtmlAsPdf() accepts the HTML string directly and returns a PdfDocument. The method names are more intuitive: RenderHtmlAsPdf vs ConvertHtmlToPdf. Learn more in our tutorials.

Example 3: Text Extraction from PDF

Before (PDFView4NET):

// NuGet: Install-Package O2S.Components.PDFView4NET
using O2S.Components.PDFView4NET;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        using (FileStream fs = File.OpenRead("document.pdf"))
        {
            PDFDocument document = new PDFDocument(fs);
            string text = "";
            for (int i = 0; i < document.Pages.Count; i++)
            {
                text += document.Pages[i].ExtractText();
            }
            Console.WriteLine(text);
        }
    }
}
// NuGet: Install-Package O2S.Components.PDFView4NET
using O2S.Components.PDFView4NET;
using System;
using System.IO;

class Program
{
    static void Main()
    {
        using (FileStream fs = File.OpenRead("document.pdf"))
        {
            PDFDocument document = new PDFDocument(fs);
            string text = "";
            for (int i = 0; i < document.Pages.Count; i++)
            {
                text += document.Pages[i].ExtractText();
            }
            Console.WriteLine(text);
        }
    }
}
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");
        string text = pdf.ExtractAllText();
        Console.WriteLine(text);
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;

class Program
{
    static void Main()
    {
        var pdf = PdfDocument.FromFile("document.pdf");
        string text = pdf.ExtractAllText();
        Console.WriteLine(text);
    }
}
$vbLabelText   $csharpLabel

This example highlights a significant API difference. PDFView4NET requires manually creating a FileStream, instantiating PDFDocument with the stream, then looping through document.Pages.Count and concatenating Pages[i].ExtractText() for each page.

IronPDF simplifies this dramatically: PdfDocument.FromFile() loads the PDF directly from a path, and ExtractAllText() extracts text from all pages in a single method call. No manual stream management, no loops, no string concatenation—just two lines of code.


Critical Migration Notes

Converter Class Change

PDFView4NET uses HtmlToPdfConverter; IronPDF uses ChromePdfRenderer:

// PDFView4NET
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// IronPDF
var renderer = new ChromePdfRenderer();
// PDFView4NET
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// IronPDF
var renderer = new ChromePdfRenderer();
$vbLabelText   $csharpLabel

Property-Based vs Method-Based API

PDFView4NET sets properties before conversion:

// PDFView4NET: Set properties, then convert
converter.HtmlContent = htmlContent;
converter.NavigateUri = new Uri(url);
converter.ConvertHtmlToPdf();
converter.SavePdf("output.pdf");

// IronPDF: Method parameters with fluent API
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
var pdf = renderer.RenderUrlAsPdf(url);
pdf.SaveAs("output.pdf");
// PDFView4NET: Set properties, then convert
converter.HtmlContent = htmlContent;
converter.NavigateUri = new Uri(url);
converter.ConvertHtmlToPdf();
converter.SavePdf("output.pdf");

// IronPDF: Method parameters with fluent API
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
var pdf = renderer.RenderUrlAsPdf(url);
pdf.SaveAs("output.pdf");
$vbLabelText   $csharpLabel

Document Loading Change

// PDFView4NET: Requires FileStream
using (FileStream fs = File.OpenRead("document.pdf"))
{
    PDFDocument document = new PDFDocument(fs);
}

// IronPDF: Direct file path
var pdf = PdfDocument.FromFile("document.pdf");
// PDFView4NET: Requires FileStream
using (FileStream fs = File.OpenRead("document.pdf"))
{
    PDFDocument document = new PDFDocument(fs);
}

// IronPDF: Direct file path
var pdf = PdfDocument.FromFile("document.pdf");
$vbLabelText   $csharpLabel

Page Access Change

// PDFView4NET: document.Pages.Count and Pages[i]
for (int i = 0; i < document.Pages.Count; i++)
{
    document.Pages[i].ExtractText();
}

// IronPDF: pdf.PageCount and Pages[i] or ExtractAllText()
string text = pdf.ExtractAllText();
// Or per-page: pdf.ExtractTextFromPage(0);
// PDFView4NET: document.Pages.Count and Pages[i]
for (int i = 0; i < document.Pages.Count; i++)
{
    document.Pages[i].ExtractText();
}

// IronPDF: pdf.PageCount and Pages[i] or ExtractAllText()
string text = pdf.ExtractAllText();
// Or per-page: pdf.ExtractTextFromPage(0);
$vbLabelText   $csharpLabel

Save Method Change

// PDFView4NET: SavePdf()
converter.SavePdf("output.pdf");

// IronPDF: SaveAs()
pdf.SaveAs("output.pdf");
// PDFView4NET: SavePdf()
converter.SavePdf("output.pdf");

// IronPDF: SaveAs()
pdf.SaveAs("output.pdf");
$vbLabelText   $csharpLabel

New Capabilities After Migration

After migrating to IronPDF, you gain capabilities that PDFView4NET cannot provide:

PDF Merging

var pdf1 = PdfDocument.FromFile("chapter1.pdf");
var pdf2 = PdfDocument.FromFile("chapter2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("complete_book.pdf");
var pdf1 = PdfDocument.FromFile("chapter1.pdf");
var pdf2 = PdfDocument.FromFile("chapter2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("complete_book.pdf");
$vbLabelText   $csharpLabel

Watermarks with HTML

var pdf = PdfDocument.FromFile("document.pdf");
pdf.ApplyWatermark(@"
    <div style='
        font-size: 72pt;
        color: rgba(255, 0, 0, 0.2);
        transform: rotate(-45deg);
    '>
        CONFIDENTIAL
    </div>");
pdf.SaveAs("watermarked.pdf");
var pdf = PdfDocument.FromFile("document.pdf");
pdf.ApplyWatermark(@"
    <div style='
        font-size: 72pt;
        color: rgba(255, 0, 0, 0.2);
        transform: rotate(-45deg);
    '>
        CONFIDENTIAL
    </div>");
pdf.SaveAs("watermarked.pdf");
$vbLabelText   $csharpLabel

Password Protection

var pdf = PdfDocument.FromFile("document.pdf");
pdf.SecuritySettings.OwnerPassword = "owner123";
pdf.SecuritySettings.UserPassword = "user456";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SaveAs("protected.pdf");
var pdf = PdfDocument.FromFile("document.pdf");
pdf.SecuritySettings.OwnerPassword = "owner123";
pdf.SecuritySettings.UserPassword = "user456";
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SaveAs("protected.pdf");
$vbLabelText   $csharpLabel

Form Filling

var pdf = PdfDocument.FromFile("form.pdf");
pdf.Form.GetFieldByName("FirstName").Value = "John";
pdf.Form.GetFieldByName("LastName").Value = "Doe";
pdf.SaveAs("filled_form.pdf");
var pdf = PdfDocument.FromFile("form.pdf");
pdf.Form.GetFieldByName("FirstName").Value = "John";
pdf.Form.GetFieldByName("LastName").Value = "Doe";
pdf.SaveAs("filled_form.pdf");
$vbLabelText   $csharpLabel

Server-Side Processing

PDFView4NET cannot run in server environments. IronPDF excels here:

// ASP.NET Core
[HttpGet]
public IActionResult GeneratePdf()
{
    var renderer = new ChromePdfRenderer();
    var pdf = renderer.RenderHtmlAsPdf(GetReportHtml());
    return File(pdf.BinaryData, "application/pdf", "report.pdf");
}
// ASP.NET Core
[HttpGet]
public IActionResult GeneratePdf()
{
    var renderer = new ChromePdfRenderer();
    var pdf = renderer.RenderHtmlAsPdf(GetReportHtml());
    return File(pdf.BinaryData, "application/pdf", "report.pdf");
}
$vbLabelText   $csharpLabel

Feature Comparison Summary

FeaturePDFView4NETIronPDF
View PDFsYes (UI)No (use viewer)
Load PDFsYesYes
Save PDFsLimitedYes
HTML to PDFNoYes
URL to PDFNoYes
Merge PDFsNoYes
Split PDFsLimitedYes
WatermarksNoYes
Headers/FootersNoYes
Password ProtectionNoYes
Digital SignaturesNoYes
Text ExtractionLimitedYes
Fill FormsLimitedYes
WinFormsYesYes
WPFYesYes
ConsoleLimitedYes
ASP.NETNoYes
AzureNoYes
DockerNoYes

Migration Checklist

Pre-Migration

  • Identify viewing requirements (determine if IronPDF's capabilities can replace UI-based PDF viewing)
  • Document printing workflows
  • List PDF manipulation needs
  • Plan viewer replacement if needed (IronPDF focuses on generation/manipulation)
  • Obtain IronPDF license key from ironpdf.com

Package Changes

  • Remove O2S.Components.PDFView4NET NuGet package
  • Install IronPdf NuGet package: dotnet add package IronPdf

Code Changes

  • Update namespace imports (using O2S.Components.PDFView4NET;using IronPdf;)
  • Replace HtmlToPdfConverter with ChromePdfRenderer
  • Replace converter.HtmlContent + ConvertHtmlToPdf() with renderer.RenderHtmlAsPdf(html)
  • Replace converter.NavigateUri + ConvertHtmlToPdf() with renderer.RenderUrlAsPdf(url)
  • Replace converter.SavePdf() with pdf.SaveAs()
  • Replace PDFDocument(stream) with PdfDocument.FromFile(path)
  • Replace manual page loop extraction with pdf.ExtractAllText()
  • Add license initialization at application startup

Post-Migration

  • Test PDF loading and saving
  • Verify text extraction functionality
  • Test HTML to PDF conversion
  • Verify server deployment works (new capability)
  • Test cross-platform if needed (new capability)
  • Remove UI-specific PDF code if server-only

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