Skip to footer content
MIGRATION GUIDES

How to Migrate from NReco PDF Generator to IronPDF in C#

Why Migrate from NReco PDF Generator to IronPDF

Critical Security Issues with NReco PDF Generator

NReco PDF Generator wraps the deprecated wkhtmltopdf binary, inheriting all its security vulnerabilities. This is not a theoretical concern—there are 20+ documented CVEs with no patches available since wkhtmltopdf was abandoned in 2020:

  • CVE-2020-21365: Server-side request forgery (SSRF)
  • CVE-2022-35583: Local file read via HTML injection
  • CVE-2022-35580: Remote code execution potential

These vulnerabilities cannot be patched because the underlying wkhtmltopdf project is no longer maintained.

Additional NReco PDF Generator Limitations

  1. Watermarked Free Version: Production use requires a paid license with opaque pricing that requires contacting sales.

  2. Deprecated Rendering Engine: WebKit Qt (circa 2012) provides limited modern web support:

    • No CSS Grid or Flexbox
    • No modern JavaScript (ES6+)
    • Poor web font support
    • No CSS variables or custom properties
  3. External Binary Dependency: Requires managing wkhtmltopdf binaries per platform (wkhtmltopdf.exe, wkhtmltox.dll).

  4. No Active Development: The wrapper receives maintenance without underlying engine updates.

  5. Limited Async Support: Synchronous API blocks threads in web applications.

NReco PDF Generator vs IronPDF Comparison

Aspect NReco PDF Generator IronPDF
Rendering Engine WebKit Qt (2012) Chromium (current)
Security 20+ CVEs, no patches Active security updates
CSS Support CSS2.1, limited CSS3 Full CSS3, Grid, Flexbox
JavaScript Basic ES5 Full ES6+, async/await
Dependencies External wkhtmltopdf binary Self-contained
Async Support Synchronous only Full async/await
Web Fonts Limited Full Google Fonts, @font-face
Licensing Opaque pricing, contact sales Transparent pricing
Free Trial Watermarked Full functionality

For teams planning .NET 10 and C# 14 adoption through 2025 and 2026, IronPDF provides a future-proof foundation with active development and modern rendering 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 NReco.PdfGenerator
dotnet remove package NReco.PdfGenerator

# Install IronPDF
dotnet add package IronPdf
# Remove NReco.PdfGenerator
dotnet remove package NReco.PdfGenerator

# Install IronPDF
dotnet add package IronPdf
SHELL

Also remove wkhtmltopdf binaries from your deployment:

  • Delete wkhtmltopdf.exe, wkhtmltox.dll from project
  • Remove any wkhtmltopdf installation scripts
  • Delete platform-specific binary folders

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";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText   $csharpLabel

Identify NReco PDF Generator Usage

# Find all NReco.PdfGenerator references
grep -r "NReco.PdfGenerator\|HtmlToPdfConverter\|GeneratePdf" --include="*.cs" .
# Find all NReco.PdfGenerator references
grep -r "NReco.PdfGenerator\|HtmlToPdfConverter\|GeneratePdf" --include="*.cs" .
SHELL

Complete API Reference

Core Class Mappings

NReco PDF Generator IronPDF
HtmlToPdfConverter ChromePdfRenderer
PageMargins Individual margin properties
PageOrientation PdfPaperOrientation
PageSize PdfPaperSize

Rendering Method Mappings

NReco PDF Generator IronPDF
GeneratePdf(html) RenderHtmlAsPdf(html)
GeneratePdfFromFile(url, output) RenderUrlAsPdf(url)
GeneratePdfFromFile(htmlPath, output) RenderHtmlFileAsPdf(path)
(async not supported) RenderHtmlAsPdfAsync(html)
(async not supported) RenderUrlAsPdfAsync(url)

Page Configuration Mappings

NReco PDF Generator IronPDF
PageWidth = 210 RenderingOptions.PaperSize = PdfPaperSize.A4
PageHeight = 297 RenderingOptions.SetCustomPaperSizeinMilimeters(w, h)
Orientation = PageOrientation.Landscape RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape
Size = PageSize.A4 RenderingOptions.PaperSize = PdfPaperSize.A4

Margin Mappings

NReco PDF Generator IronPDF
Margins.Top = 10 RenderingOptions.MarginTop = 10
Margins.Bottom = 10 RenderingOptions.MarginBottom = 10
Margins.Left = 10 RenderingOptions.MarginLeft = 10
Margins.Right = 10 RenderingOptions.MarginRight = 10
new PageMargins { ... } Individual properties
NReco PDF Generator (wkhtmltopdf) IronPDF
[page] {page}
[topage] {total-pages}
[date] {date}
[time] {time}
[title] {html-title}

Output Handling Mappings

NReco PDF Generator IronPDF
byte[] pdfBytes = GeneratePdf(html) PdfDocument pdf = RenderHtmlAsPdf(html)
File.WriteAllBytes(path, bytes) pdf.SaveAs(path)
return pdfBytes return pdf.BinaryData
new MemoryStream(pdfBytes) pdf.Stream

Code Migration Examples

Example 1: Basic HTML to PDF

Before (NReco PDF Generator):

// NuGet: Install-Package NReco.PdfGenerator
using NReco.PdfGenerator;
using System.IO;

class Program
{
    static void Main()
    {
        var htmlToPdf = new HtmlToPdfConverter();
        var htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
        File.WriteAllBytes("output.pdf", pdfBytes);
    }
}
// NuGet: Install-Package NReco.PdfGenerator
using NReco.PdfGenerator;
using System.IO;

class Program
{
    static void Main()
    {
        var htmlToPdf = new HtmlToPdfConverter();
        var htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
        File.WriteAllBytes("output.pdf", pdfBytes);
    }
}
Imports NReco.PdfGenerator
Imports System.IO

Class Program
    Shared Sub Main()
        Dim htmlToPdf = New HtmlToPdfConverter()
        Dim htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"
        Dim pdfBytes = htmlToPdf.GeneratePdf(htmlContent)
        File.WriteAllBytes("output.pdf", pdfBytes)
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

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

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("output.pdf");
    }
}
Imports IronPdf
Imports System.IO

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        Dim htmlContent = "<html><body><h1>Hello World</h1><p>This is a PDF document.</p></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("output.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

The fundamental difference is in the return type and save pattern. NReco PDF Generator's HtmlToPdfConverter.GeneratePdf() returns a byte[] that you must manually write to disk using File.WriteAllBytes(). IronPDF's ChromePdfRenderer.RenderHtmlAsPdf() returns a PdfDocument object with a built-in SaveAs() method.

This object-oriented approach provides additional benefits: you can manipulate the PDF (add watermarks, merge documents, add security) before saving. If you need the raw bytes for compatibility with existing code, use pdf.BinaryData. See the HTML to PDF documentation for additional rendering options.

Example 2: Custom Page Size with Margins

Before (NReco PDF Generator):

// NuGet: Install-Package NReco.PdfGenerator
using NReco.PdfGenerator;
using System.IO;

class Program
{
    static void Main()
    {
        var htmlToPdf = new HtmlToPdfConverter();
        htmlToPdf.PageWidth = 210;
        htmlToPdf.PageHeight = 297;
        htmlToPdf.Margins = new PageMargins { Top = 10, Bottom = 10, Left = 10, Right = 10 };
        var htmlContent = "<html><body><h1>Custom Page Size</h1><p>A4 size document with margins.</p></body></html>";
        var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
        File.WriteAllBytes("custom-size.pdf", pdfBytes);
    }
}
// NuGet: Install-Package NReco.PdfGenerator
using NReco.PdfGenerator;
using System.IO;

class Program
{
    static void Main()
    {
        var htmlToPdf = new HtmlToPdfConverter();
        htmlToPdf.PageWidth = 210;
        htmlToPdf.PageHeight = 297;
        htmlToPdf.Margins = new PageMargins { Top = 10, Bottom = 10, Left = 10, Right = 10 };
        var htmlContent = "<html><body><h1>Custom Page Size</h1><p>A4 size document with margins.</p></body></html>";
        var pdfBytes = htmlToPdf.GeneratePdf(htmlContent);
        File.WriteAllBytes("custom-size.pdf", pdfBytes);
    }
}
Imports NReco.PdfGenerator
Imports System.IO

Class Program
    Shared Sub Main()
        Dim htmlToPdf = New HtmlToPdfConverter()
        htmlToPdf.PageWidth = 210
        htmlToPdf.PageHeight = 297
        htmlToPdf.Margins = New PageMargins With {.Top = 10, .Bottom = 10, .Left = 10, .Right = 10}
        Dim htmlContent = "<html><body><h1>Custom Page Size</h1><p>A4 size document with margins.</p></body></html>"
        Dim pdfBytes = htmlToPdf.GeneratePdf(htmlContent)
        File.WriteAllBytes("custom-size.pdf", pdfBytes)
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.MarginTop = 10;
        renderer.RenderingOptions.MarginBottom = 10;
        renderer.RenderingOptions.MarginLeft = 10;
        renderer.RenderingOptions.MarginRight = 10;
        var htmlContent = "<html><body><h1>Custom Page Size</h1><p>A4 size document with margins.</p></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("custom-size.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4;
        renderer.RenderingOptions.MarginTop = 10;
        renderer.RenderingOptions.MarginBottom = 10;
        renderer.RenderingOptions.MarginLeft = 10;
        renderer.RenderingOptions.MarginRight = 10;
        var htmlContent = "<html><body><h1>Custom Page Size</h1><p>A4 size document with margins.</p></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(htmlContent);
        pdf.SaveAs("custom-size.pdf");
    }
}
Imports IronPdf
Imports IronPdf.Rendering

Class Program
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()
        renderer.RenderingOptions.PaperSize = PdfPaperSize.A4
        renderer.RenderingOptions.MarginTop = 10
        renderer.RenderingOptions.MarginBottom = 10
        renderer.RenderingOptions.MarginLeft = 10
        renderer.RenderingOptions.MarginRight = 10
        Dim htmlContent = "<html><body><h1>Custom Page Size</h1><p>A4 size document with margins.</p></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
        pdf.SaveAs("custom-size.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

NReco PDF Generator uses numeric dimensions (PageWidth = 210, PageHeight = 297) and a PageMargins object. IronPDF uses the PdfPaperSize enum (which includes standard sizes like A4, Letter, Legal) and individual margin properties on the RenderingOptions object.

The key migration changes:

  • PageWidth/PageHeightRenderingOptions.PaperSize = PdfPaperSize.A4
  • new PageMargins { Top = 10, ... } → Individual properties: RenderingOptions.MarginTop = 10

For custom paper sizes not covered by the enum, use RenderingOptions.SetCustomPaperSizeinMilimeters(width, height). Learn more about page configuration options.

Example 3: URL to PDF Conversion

Before (NReco PDF Generator):

// NuGet: Install-Package NReco.PdfGenerator
using NReco.PdfGenerator;
using System.IO;

class Program
{
    static void Main()
    {
        var htmlToPdf = new HtmlToPdfConverter();
        var pdfBytes = htmlToPdf.GeneratePdfFromFile("https://www.example.com", null);
        File.WriteAllBytes("webpage.pdf", pdfBytes);
    }
}
// NuGet: Install-Package NReco.PdfGenerator
using NReco.PdfGenerator;
using System.IO;

class Program
{
    static void Main()
    {
        var htmlToPdf = new HtmlToPdfConverter();
        var pdfBytes = htmlToPdf.GeneratePdfFromFile("https://www.example.com", null);
        File.WriteAllBytes("webpage.pdf", pdfBytes);
    }
}
Imports NReco.PdfGenerator
Imports System.IO

Class Program
    Shared Sub Main()
        Dim htmlToPdf As New HtmlToPdfConverter()
        Dim pdfBytes As Byte() = htmlToPdf.GeneratePdfFromFile("https://www.example.com", Nothing)
        File.WriteAllBytes("webpage.pdf", pdfBytes)
    End Sub
End Class
$vbLabelText   $csharpLabel

After (IronPDF):

// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        var pdf = renderer.RenderUrlAsPdf("https://www.example.com");
        pdf.SaveAs("webpage.pdf");
    }
}
Imports IronPdf

Class Program
    Shared Sub Main()
        Dim renderer As New ChromePdfRenderer()
        Dim pdf = renderer.RenderUrlAsPdf("https://www.example.com")
        pdf.SaveAs("webpage.pdf")
    End Sub
End Class
$vbLabelText   $csharpLabel

NReco PDF Generator uses the confusingly named GeneratePdfFromFile() method for both local files and URLs, with a nullable second parameter. IronPDF provides dedicated methods: RenderUrlAsPdf() for URLs and RenderHtmlFileAsPdf() for local HTML files.

The IronPDF approach is cleaner and more intuitive. For async web applications, use await renderer.RenderUrlAsPdfAsync(url) to avoid blocking threads—something NReco PDF Generator simply cannot do.


Critical Migration Notes

Zoom Value Conversion

NReco PDF Generator uses float values (0.0-2.0), while IronPDF uses percentage integers:

// NReco PDF Generator: Zoom = 0.9f (90%)
// IronPDF: Zoom = 90

// Conversion formula:
int ironPdfZoom = (int)(nrecoZoom * 100);
// NReco PDF Generator: Zoom = 0.9f (90%)
// IronPDF: Zoom = 90

// Conversion formula:
int ironPdfZoom = (int)(nrecoZoom * 100);
' NReco PDF Generator: Zoom = 0.9F (90%)
' IronPDF: Zoom = 90

' Conversion formula:
Dim ironPdfZoom As Integer = CInt(nrecoZoom * 100)
$vbLabelText   $csharpLabel

Placeholder Syntax Update

All header/footer placeholders must be updated:

NReco PDF Generator IronPDF
[page] {page}
[topage] {total-pages}
[date] {date}
[title] {html-title}
// NReco PDF Generator:
converter.PageFooterHtml = "<div>Page [page] of [topage]</div>";

// IronPDF:
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
    HtmlFragment = "<div>Page {page} of {total-pages}</div>",
    MaxHeight = 20
};
// NReco PDF Generator:
converter.PageFooterHtml = "<div>Page [page] of [topage]</div>";

// IronPDF:
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
    HtmlFragment = "<div>Page {page} of {total-pages}</div>",
    MaxHeight = 20
};
Imports NReco.PdfGenerator
Imports IronPdf

' NReco PDF Generator:
converter.PageFooterHtml = "<div>Page [page] of [topage]</div>"

' IronPDF:
renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter With {
    .HtmlFragment = "<div>Page {page} of {total-pages}</div>",
    .MaxHeight = 20
}
$vbLabelText   $csharpLabel

Return Type Change

NReco PDF Generator returns byte[] directly; IronPDF returns PdfDocument:

// NReco PDF Generator pattern:
byte[] pdfBytes = converter.GeneratePdf(html);
File.WriteAllBytes("output.pdf", pdfBytes);

// IronPDF pattern:
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");

// Or if you need bytes:
byte[] pdfBytes = renderer.RenderHtmlAsPdf(html).BinaryData;
// NReco PDF Generator pattern:
byte[] pdfBytes = converter.GeneratePdf(html);
File.WriteAllBytes("output.pdf", pdfBytes);

// IronPDF pattern:
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");

// Or if you need bytes:
byte[] pdfBytes = renderer.RenderHtmlAsPdf(html).BinaryData;
' NReco PDF Generator pattern:
Dim pdfBytes As Byte() = converter.GeneratePdf(html)
File.WriteAllBytes("output.pdf", pdfBytes)

' IronPDF pattern:
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")

' Or if you need bytes:
Dim pdfBytes As Byte() = renderer.RenderHtmlAsPdf(html).BinaryData
$vbLabelText   $csharpLabel

Thread Safety and Reusability

NReco PDF Generator typically creates a new converter per call. IronPDF's ChromePdfRenderer is thread-safe and can be reused:

// NReco PDF Generator pattern (creates new each time):
public byte[] Generate(string html)
{
    var converter = new HtmlToPdfConverter();
    return converter.GeneratePdf(html);
}

// IronPDF pattern (reuse renderer, thread-safe):
private readonly ChromePdfRenderer _renderer = new ChromePdfRenderer();

public byte[] Generate(string html)
{
    return _renderer.RenderHtmlAsPdf(html).BinaryData;
}
// NReco PDF Generator pattern (creates new each time):
public byte[] Generate(string html)
{
    var converter = new HtmlToPdfConverter();
    return converter.GeneratePdf(html);
}

// IronPDF pattern (reuse renderer, thread-safe):
private readonly ChromePdfRenderer _renderer = new ChromePdfRenderer();

public byte[] Generate(string html)
{
    return _renderer.RenderHtmlAsPdf(html).BinaryData;
}
' NReco PDF Generator pattern (creates new each time):
Public Function Generate(html As String) As Byte()
    Dim converter As New HtmlToPdfConverter()
    Return converter.GeneratePdf(html)
End Function

' IronPDF pattern (reuse renderer, thread-safe):
Private ReadOnly _renderer As New ChromePdfRenderer()

Public Function Generate(html As String) As Byte()
    Return _renderer.RenderHtmlAsPdf(html).BinaryData
End Function
$vbLabelText   $csharpLabel

Async Support (New Capability)

IronPDF supports async/await patterns that NReco PDF Generator cannot provide:

// NReco PDF Generator: No async support available

// IronPDF: Full async support
public async Task<byte[]> GenerateAsync(string html)
{
    var pdf = await _renderer.RenderHtmlAsPdfAsync(html);
    return pdf.BinaryData;
}
// NReco PDF Generator: No async support available

// IronPDF: Full async support
public async Task<byte[]> GenerateAsync(string html)
{
    var pdf = await _renderer.RenderHtmlAsPdfAsync(html);
    return pdf.BinaryData;
}
Imports System.Threading.Tasks

' NReco PDF Generator: No async support available

' IronPDF: Full async support
Public Async Function GenerateAsync(html As String) As Task(Of Byte())
    Dim pdf = Await _renderer.RenderHtmlAsPdfAsync(html)
    Return pdf.BinaryData
End Function
$vbLabelText   $csharpLabel

Troubleshooting

Issue 1: HtmlToPdfConverter Not Found

Problem: HtmlToPdfConverter class doesn't exist in IronPDF.

Solution: Use ChromePdfRenderer:

// NReco PDF Generator
var converter = new HtmlToPdfConverter();

// IronPDF
var renderer = new ChromePdfRenderer();
// NReco PDF Generator
var converter = new HtmlToPdfConverter();

// IronPDF
var renderer = new ChromePdfRenderer();
' NReco PDF Generator
Dim converter As New HtmlToPdfConverter()

' IronPDF
Dim renderer As New ChromePdfRenderer()
$vbLabelText   $csharpLabel

Issue 2: GeneratePdf Returns Wrong Type

Problem: Code expects byte[] but gets PdfDocument.

Solution: Access .BinaryData property:

// NReco PDF Generator
byte[] pdfBytes = converter.GeneratePdf(html);

// IronPDF
byte[] pdfBytes = renderer.RenderHtmlAsPdf(html).BinaryData;
// NReco PDF Generator
byte[] pdfBytes = converter.GeneratePdf(html);

// IronPDF
byte[] pdfBytes = renderer.RenderHtmlAsPdf(html).BinaryData;
' NReco PDF Generator
Dim pdfBytes As Byte() = converter.GeneratePdf(html)

' IronPDF
Dim pdfBytes As Byte() = renderer.RenderHtmlAsPdf(html).BinaryData
$vbLabelText   $csharpLabel

Issue 3: PageMargins Object Not Found

Problem: PageMargins class doesn't exist in IronPDF.

Solution: Use individual margin properties:

// NReco PDF Generator
converter.Margins = new PageMargins { Top = 10, Bottom = 10, Left = 10, Right = 10 };

// IronPDF
renderer.RenderingOptions.MarginTop = 10;
renderer.RenderingOptions.MarginBottom = 10;
renderer.RenderingOptions.MarginLeft = 10;
renderer.RenderingOptions.MarginRight = 10;
// NReco PDF Generator
converter.Margins = new PageMargins { Top = 10, Bottom = 10, Left = 10, Right = 10 };

// IronPDF
renderer.RenderingOptions.MarginTop = 10;
renderer.RenderingOptions.MarginBottom = 10;
renderer.RenderingOptions.MarginLeft = 10;
renderer.RenderingOptions.MarginRight = 10;
' NReco PDF Generator
converter.Margins = New PageMargins With {.Top = 10, .Bottom = 10, .Left = 10, .Right = 10}

' IronPDF
renderer.RenderingOptions.MarginTop = 10
renderer.RenderingOptions.MarginBottom = 10
renderer.RenderingOptions.MarginLeft = 10
renderer.RenderingOptions.MarginRight = 10
$vbLabelText   $csharpLabel

Issue 4: Page Numbers Not Appearing

Problem: [page] and [topage] placeholders don't work.

Solution: Update to IronPDF placeholder syntax:

// NReco PDF Generator
converter.PageFooterHtml = "<div>Page [page] of [topage]</div>";

// IronPDF
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
    HtmlFragment = "<div>Page {page} of {total-pages}</div>",
    MaxHeight = 20
};
// NReco PDF Generator
converter.PageFooterHtml = "<div>Page [page] of [topage]</div>";

// IronPDF
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
    HtmlFragment = "<div>Page {page} of {total-pages}</div>",
    MaxHeight = 20
};
Imports NReco.PdfGenerator
Imports IronPdf

converter.PageFooterHtml = "<div>Page [page] of [topage]</div>"

renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter With {
    .HtmlFragment = "<div>Page {page} of {total-pages}</div>",
    .MaxHeight = 20
}
$vbLabelText   $csharpLabel

Migration Checklist

Pre-Migration

  • Inventory all NReco.PdfGenerator usages in codebase
  • Document all CustomWkHtmlArgs and CustomWkHtmlPageArgs values
  • List all header/footer HTML templates with placeholders
  • Identify async requirements (web controllers, services)
  • Review zoom and margin settings
  • Backup existing PDF outputs for comparison
  • Obtain IronPDF license key

Package Changes

  • Remove NReco.PdfGenerator NuGet package
  • Install IronPdf NuGet package: dotnet add package IronPdf
  • Update namespace imports from using NReco.PdfGenerator; to using IronPdf;

Code Changes

  • Add license key configuration at startup
  • Replace HtmlToPdfConverter with ChromePdfRenderer
  • Replace GeneratePdf(html) with RenderHtmlAsPdf(html)
  • Replace GeneratePdfFromFile(url, null) with RenderUrlAsPdf(url)
  • Convert PageMargins object to individual margin properties
  • Update zoom values from float to percentage
  • Update placeholder syntax: [page]{page}, [topage]{total-pages}
  • Replace File.WriteAllBytes() with pdf.SaveAs()
  • Convert sync calls to async where beneficial

Post-Migration

  • Remove wkhtmltopdf binaries from project/deployment
  • Update Docker files to remove wkhtmltopdf installation
  • Run regression tests comparing PDF output
  • Verify header/footer placeholders render correctly
  • Test on all target platforms (Windows, Linux, macOS)
  • Update CI/CD pipeline to remove wkhtmltopdf steps
  • Update security scanning to confirm CVE removal

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

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me