Skip to footer content
MIGRATION GUIDES

How to Migrate from XFINIUM.PDF to IronPDF in C#

XFINIUM.PDF is a cross-platform PDF library that offers comprehensive tools for creating and editing PDFs programmatically in C#. While it provides two editions—Generator and Viewer—the library's reliance on coordinate-based graphics programming creates significant challenges for development teams building document-heavy applications. Every element must be manually positioned using pixel coordinates, turning what should be simple documents into complex drawing exercises.

This guide provides a complete migration path from XFINIUM.PDF to IronPDF, with step-by-step instructions, code comparisons, and practical examples for professional .NET developers evaluating this transition.

Why Migrate from XFINIUM.PDF

XFINIUM.PDF is a low-level PDF library that relies on coordinate-based graphics programming, forcing developers to manually position every element on the page. This approach becomes a maintenance nightmare as requirements change. Key reasons development teams consider migration include:

No HTML Support: XFINIUM.PDF cannot convert HTML/CSS to PDF directly. It focuses on programmatic PDF creation using low-level drawing primitives, which may not suffice for projects requiring extensive HTML-to-PDF capabilities.

Coordinate-Based API: Manual positioning with pixel coordinates like DrawString("text", font, brush, 50, 100) is required for every element on the page.

Manual Font Management: Font objects must be created and managed explicitly using classes like PdfStandardFont and PdfBrush.

No CSS Styling: No support for modern web styling. Colors, fonts, and layouts must be handled manually through programmatic method calls.

No JavaScript Rendering: Static content only. XFINIUM.PDF cannot render dynamic web content or execute JavaScript.

Complex Text Layout: Manual text measurement and wrapping calculations are required for anything beyond simple single-line text.

Limited Community Resources: There is a lack of community-provided resources such as examples and tutorials compared to mainstream solutions, which can make it harder for new users to get started.

The Core Problem: Graphics API vs HTML

XFINIUM.PDF forces you to think like a graphics programmer, not a document designer:

// XFINIUM.PDF: Position every element manually
page.Graphics.DrawString("Invoice", titleFont, titleBrush, 50, 50);
page.Graphics.DrawString("Customer:", labelFont, brush, 50, 80);
page.Graphics.DrawString(customer.Name, valueFont, brush, 120, 80);
// ... hundreds of lines for a simple document
// XFINIUM.PDF: Position every element manually
page.Graphics.DrawString("Invoice", titleFont, titleBrush, 50, 50);
page.Graphics.DrawString("Customer:", labelFont, brush, 50, 80);
page.Graphics.DrawString(customer.Name, valueFont, brush, 120, 80);
// ... hundreds of lines for a simple document
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF uses familiar HTML/CSS:

// IronPDF: Declarative HTML
var html = @"<h1>Invoice</h1><p><b>Customer:</b> " + customer.Name + "</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
// IronPDF: Declarative HTML
var html = @"<h1>Invoice</h1><p><b>Customer:</b> " + customer.Name + "</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF vs XFINIUM.PDF: Feature Comparison

Understanding the architectural differences helps technical decision-makers evaluate the migration investment:

FeatureXFINIUM.PDFIronPDF
HTML to PDFLimited HTML support, focuses on programmatic PDF creationFull HTML-to-PDF conversion with comprehensive support
Community & SupportSmaller community, fewer online resources availableLarge community with extensive documentation and tutorials
LicenseCommercial with developer-based licensingCommercial
Cross-Platform SupportStrong cross-platform capabilitiesAlso supports cross-platform operations
CSS SupportNoFull CSS3
JavaScriptNoFull ES2024
Flexbox/GridNoYes
Automatic LayoutNoYes
Automatic Page BreaksNoYes
Manual PositioningRequiredOptional (CSS positioning)
Learning CurveHigh (coordinate system)Low (HTML/CSS)
Code VerbosityVery HighLow

Quick Start: XFINIUM.PDF to IronPDF Migration

The migration can begin immediately with these foundational steps.

Step 1: Replace NuGet Package

Remove XFINIUM.PDF:

# Remove XFINIUM.PDF
dotnet remove package Xfinium.Pdf
# Remove XFINIUM.PDF
dotnet remove package Xfinium.Pdf
SHELL

Install IronPDF:

# Install IronPDF
dotnet add package IronPdf
# Install IronPDF
dotnet add package IronPdf
SHELL

Step 2: Update Namespaces

Replace XFINIUM.PDF namespaces with the IronPdf namespace:

// Before (XFINIUM.PDF)
using Xfinium.Pdf;
using Xfinium.Pdf.Graphics;
using Xfinium.Pdf.Content;
using Xfinium.Pdf.FlowDocument;

// After (IronPDF)
using IronPdf;
// Before (XFINIUM.PDF)
using Xfinium.Pdf;
using Xfinium.Pdf.Graphics;
using Xfinium.Pdf.Content;
using Xfinium.Pdf.FlowDocument;

// After (IronPDF)
using IronPdf;
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Step 3: Initialize License

Add license initialization at application startup:

IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

Code Migration Examples

Converting HTML to PDF

The most fundamental operation reveals the complexity difference between these .NET PDF libraries.

XFINIUM.PDF Approach:

// NuGet: Install-Package Xfinium.Pdf
using Xfinium.Pdf;
using Xfinium.Pdf.Actions;
using Xfinium.Pdf.FlowDocument;
using System.IO;

class Program
{
    static void Main()
    {
        PdfFixedDocument document = new PdfFixedDocument();
        PdfFlowDocument flowDocument = new PdfFlowDocument();

        string html = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>";

        PdfFlowContent content = new PdfFlowContent();
        content.AppendHtml(html);
        flowDocument.AddContent(content);

        flowDocument.RenderDocument(document);
        document.Save("output.pdf");
    }
}
// NuGet: Install-Package Xfinium.Pdf
using Xfinium.Pdf;
using Xfinium.Pdf.Actions;
using Xfinium.Pdf.FlowDocument;
using System.IO;

class Program
{
    static void Main()
    {
        PdfFixedDocument document = new PdfFixedDocument();
        PdfFlowDocument flowDocument = new PdfFlowDocument();

        string html = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>";

        PdfFlowContent content = new PdfFlowContent();
        content.AppendHtml(html);
        flowDocument.AddContent(content);

        flowDocument.RenderDocument(document);
        document.Save("output.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF Approach:

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string html = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        string html = "<html><body><h1>Hello World</h1><p>This is a PDF from HTML.</p></body></html>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

XFINIUM.PDF requires creating a PdfFixedDocument, a PdfFlowDocument, a PdfFlowContent object, calling AppendHtml(), adding content to the flow document, rendering to the fixed document, and finally saving. IronPDF simplifies this to three lines: create a renderer, render HTML, and save.

For advanced HTML-to-PDF scenarios, see the HTML to PDF conversion guide.

Merging Multiple PDFs

PDF merging demonstrates the API complexity differences clearly.

XFINIUM.PDF Approach:

// NuGet: Install-Package Xfinium.Pdf
using Xfinium.Pdf;
using System.IO;

class Program
{
    static void Main()
    {
        PdfFixedDocument output = new PdfFixedDocument();

        FileStream file1 = File.OpenRead("document1.pdf");
        PdfFixedDocument pdf1 = new PdfFixedDocument(file1);

        FileStream file2 = File.OpenRead("document2.pdf");
        PdfFixedDocument pdf2 = new PdfFixedDocument(file2);

        for (int i = 0; i < pdf1.Pages.Count; i++)
        {
            output.Pages.Add(pdf1.Pages[i]);
        }

        for (int i = 0; i < pdf2.Pages.Count; i++)
        {
            output.Pages.Add(pdf2.Pages[i]);
        }

        output.Save("merged.pdf");

        file1.Close();
        file2.Close();
    }
}
// NuGet: Install-Package Xfinium.Pdf
using Xfinium.Pdf;
using System.IO;

class Program
{
    static void Main()
    {
        PdfFixedDocument output = new PdfFixedDocument();

        FileStream file1 = File.OpenRead("document1.pdf");
        PdfFixedDocument pdf1 = new PdfFixedDocument(file1);

        FileStream file2 = File.OpenRead("document2.pdf");
        PdfFixedDocument pdf2 = new PdfFixedDocument(file2);

        for (int i = 0; i < pdf1.Pages.Count; i++)
        {
            output.Pages.Add(pdf1.Pages[i]);
        }

        for (int i = 0; i < pdf2.Pages.Count; i++)
        {
            output.Pages.Add(pdf2.Pages[i]);
        }

        output.Save("merged.pdf");

        file1.Close();
        file2.Close();
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF Approach:

// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        var merged = PdfDocument.Merge(pdf1, pdf2);
        merged.SaveAs("merged.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var pdf1 = PdfDocument.FromFile("document1.pdf");
        var pdf2 = PdfDocument.FromFile("document2.pdf");

        var merged = PdfDocument.Merge(pdf1, pdf2);
        merged.SaveAs("merged.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

XFINIUM.PDF requires creating an output document, opening file streams, loading each document, manually iterating through pages and adding them one by one, saving, and then closing streams. IronPDF provides a single PdfDocument.Merge() method that handles all complexity internally.

Explore the PDF merging documentation for additional merge options.

Creating PDFs with Text and Images

Documents with mixed content show the fundamental paradigm difference.

XFINIUM.PDF Approach:

// NuGet: Install-Package Xfinium.Pdf
using Xfinium.Pdf;
using Xfinium.Pdf.Graphics;
using Xfinium.Pdf.Core;
using System.IO;

class Program
{
    static void Main()
    {
        PdfFixedDocument document = new PdfFixedDocument();
        PdfPage page = document.Pages.Add();

        PdfStandardFont font = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);
        PdfBrush brush = new PdfBrush(PdfRgbColor.Black);

        page.Graphics.DrawString("Sample PDF Document", font, brush, 50, 50);

        FileStream imageStream = File.OpenRead("image.jpg");
        PdfJpegImage image = new PdfJpegImage(imageStream);
        page.Graphics.DrawImage(image, 50, 100, 200, 150);
        imageStream.Close();

        document.Save("output.pdf");
    }
}
// NuGet: Install-Package Xfinium.Pdf
using Xfinium.Pdf;
using Xfinium.Pdf.Graphics;
using Xfinium.Pdf.Core;
using System.IO;

class Program
{
    static void Main()
    {
        PdfFixedDocument document = new PdfFixedDocument();
        PdfPage page = document.Pages.Add();

        PdfStandardFont font = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);
        PdfBrush brush = new PdfBrush(PdfRgbColor.Black);

        page.Graphics.DrawString("Sample PDF Document", font, brush, 50, 50);

        FileStream imageStream = File.OpenRead("image.jpg");
        PdfJpegImage image = new PdfJpegImage(imageStream);
        page.Graphics.DrawImage(image, 50, 100, 200, 150);
        imageStream.Close();

        document.Save("output.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

IronPDF Approach:

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string imageBase64 = Convert.ToBase64String(File.ReadAllBytes("image.jpg"));
        string html = $@"
            <html>
                <body>
                    <h1>Sample PDF Document</h1>
                    <img src='data:image/jpeg;base64,{imageBase64}' width='200' height='150' />
                </body>
            </html>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System.IO;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        string imageBase64 = Convert.ToBase64String(File.ReadAllBytes("image.jpg"));
        string html = $@"
            <html>
                <body>
                    <h1>Sample PDF Document</h1>
                    <img src='data:image/jpeg;base64,{imageBase64}' width='200' height='150' />
                </body>
            </html>";

        var pdf = renderer.RenderHtmlAsPdf(html);
        pdf.SaveAs("output.pdf");
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

XFINIUM.PDF requires creating a document, adding a page, creating font and brush objects, drawing text at specific coordinates, opening an image stream, creating a PdfJpegImage, drawing the image at coordinates with dimensions, closing the stream, and saving. IronPDF uses standard HTML with embedded base64 images—the same approach web developers use daily.

XFINIUM.PDF API to IronPDF Mapping Reference

This mapping accelerates migration by showing direct API equivalents:

XFINIUM.PDFIronPDF
PdfFixedDocumentChromePdfRenderer
PdfPageAutomatic
page.Graphics.DrawString()HTML text elements
page.Graphics.DrawImage()<img> tag
page.Graphics.DrawLine()CSS border or <hr>
page.Graphics.DrawRectangle()CSS border on <div>
PdfStandardFontCSS font-family
PdfRgbColorCSS color
PdfBrushCSS properties
PdfJpegImage<img> tag with base64
document.Save(stream)pdf.SaveAs() or pdf.BinaryData
PdfFlowDocumentRenderHtmlAsPdf()
PdfFlowContent.AppendHtml()RenderHtmlAsPdf()

Common Migration Issues and Solutions

Issue 1: Coordinate-Based Layout

XFINIUM.PDF: Everything requires exact X,Y coordinates with manual positioning.

Solution: Use HTML/CSS flow layout. For absolute positioning when needed, use CSS:

.positioned-element {
    position: absolute;
    top: 100px;
    left: 50px;
}

Issue 2: Font Object Management

XFINIUM.PDF: Create PdfStandardFont or PdfUnicodeTrueTypeFont objects for each font.

Solution: Use CSS font-family—fonts are handled automatically:

<style>
    body { font-family: Arial, sans-serif; }
    h1 { font-family: 'Times New Roman', serif; font-size: 24px; }
</style>
<style>
    body { font-family: Arial, sans-serif; }
    h1 { font-family: 'Times New Roman', serif; font-size: 24px; }
</style>
HTML

Issue 3: Color Handling

XFINIUM.PDF: Create PdfRgbColor and PdfBrush objects for colors.

Solution: Use standard CSS colors:

.header { color: navy; background-color: #f5f5f5; }
.warning { color: rgb(255, 0, 0); }
.info { color: rgba(0, 0, 255, 0.8); }

Issue 4: Manual Page Breaks

XFINIUM.PDF: Track Y position and create new pages manually when content overflows.

Solution: IronPDF handles automatic page breaks. For explicit control, use CSS:

.section { page-break-after: always; }
.keep-together { page-break-inside: avoid; }

Issue 5: Image Loading

XFINIUM.PDF: Open file streams, create PdfJpegImage objects, draw at coordinates, close streams.

Solution: Use HTML <img> tags with file paths or base64 data:

<img src="image.jpg" width="200" height="150" />

<img src="data:image/jpeg;base64,..." />
<img src="image.jpg" width="200" height="150" />

<img src="data:image/jpeg;base64,..." />
HTML

XFINIUM.PDF Migration Checklist

Pre-Migration Tasks

Audit your codebase to identify all XFINIUM.PDF usage:

grep -r "using Xfinium.Pdf" --include="*.cs" .
grep -r "Graphics.DrawString\|Graphics.DrawImage\|Graphics.DrawLine" --include="*.cs" .
grep -r "using Xfinium.Pdf" --include="*.cs" .
grep -r "Graphics.DrawString\|Graphics.DrawImage\|Graphics.DrawLine" --include="*.cs" .
SHELL

Document coordinate-based layouts and note all X,Y positioning values. Identify font and color objects (PdfStandardFont, PdfRgbColor, PdfBrush). Map merged PDF workflows using PdfFixedDocument.Pages.Add().

Code Update Tasks

  1. Remove Xfinium.Pdf NuGet package
  2. Install IronPdf NuGet package
  3. Update namespace imports from Xfinium.Pdf to IronPdf
  4. Convert DrawString() calls to HTML text elements
  5. Convert DrawImage() calls to HTML <img> tags
  6. Convert DrawRectangle() and DrawLine() to CSS borders
  7. Replace PdfStandardFont with CSS font-family
  8. Replace PdfRgbColor and PdfBrush with CSS colors
  9. Replace page loop merging with PdfDocument.Merge()
  10. Add IronPDF license initialization at startup

Post-Migration Testing

After migration, verify these aspects:

  • Compare visual output to ensure appearance matches expectations
  • Verify text rendering with the new HTML/CSS approach
  • Check image positioning using CSS
  • Test page breaks occur as expected
  • Verify PDF security settings are correctly applied
  • Test on all target platforms

Key Benefits of Migrating to IronPDF

Moving from XFINIUM.PDF to IronPDF provides several critical advantages:

HTML-Based Content Creation: Web developers can leverage existing HTML and CSS skills. No need to learn coordinate-based drawing APIs or manage font and brush objects.

Automatic Layout: Text wrapping, pagination, and flow layout happen automatically. No manual calculation of element positions or page breaks.

Modern CSS Support: Full CSS3 including Flexbox and Grid layouts. Responsive designs translate directly to PDF.

Simplified PDF Operations: Single-method calls for common operations like PdfDocument.Merge() replace complex page iteration loops.

Active Development: As .NET 10 and C# 14 adoption increases through 2026, IronPDF's regular updates ensure compatibility with current and future .NET versions.

Extensive Documentation: Large community with comprehensive documentation, tutorials, and support resources compared to XFINIUM.PDF's smaller ecosystem.

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