Skip to footer content
MIGRATION GUIDES

How to Migrate from DinkToPdf to IronPDF in C#

DinkToPdf wraps wkhtmltopdf, inheriting all its security vulnerabilities and technical limitations. Understanding these issues is critical for evaluating migration urgency.

Critical Security Issues

DinkToPdf inherits critical unpatched security vulnerabilities from wkhtmltopdf:

  1. CVE-2022-35583 (SSRF): Server-Side Request Forgery allowing attackers to access internal network resources
  2. Abandoned Project: wkhtmltopdf has been unmaintained since 2020
  3. No Security Patches: Known vulnerabilities will never be fixed

Technical Problems

IssueImpact
Thread SafetySynchronizedConverter still crashes in production under concurrent load
Native BinariesComplex deployment with platform-specific libwkhtmltox binaries
CSS LimitationsNo Flexbox, Grid, or modern CSS support
JavaScriptInconsistent execution, timeouts
RenderingOutdated WebKit engine (circa 2015)
MaintenanceLast update: 2018

Architecture Comparison

AspectDinkToPdfIronPDF
SecurityCVE-2022-35583 (SSRF), unpatchedNo known vulnerabilities
Rendering EngineOutdated WebKit (2015)Modern Chromium
Thread SafetyCrashes in concurrent useFully thread-safe
Native DependenciesPlatform-specific binariesPure NuGet package
CSS SupportNo Flexbox/GridFull CSS3
JavaScriptLimited, inconsistentFull support
MaintenanceAbandoned (2018)Actively maintained

Feature Comparison

FeatureDinkToPdfIronPDF
HTML to PDF✅ (outdated engine)✅ (Chromium)
URL to PDF
Custom margins
Headers/Footers✅ (limited)✅ (full HTML)
CSS3❌ Limited✅ Full
Flexbox/Grid
JavaScript⚠️ Limited✅ Full
PDF manipulation
Form filling
Digital signatures
Encryption
Watermarks
Merge/Split

Pre-Migration Preparation

Prerequisites

Ensure your environment meets these requirements:

  • .NET Framework 4.6.2+ or .NET Core 3.1 / .NET 5-9
  • Visual Studio 2019+ or VS Code with C# extension
  • NuGet Package Manager access
  • IronPDF license key (free trial available at ironpdf.com)

Audit DinkToPdf Usage

Run these commands in your solution directory to identify all DinkToPdf references:

# Find all DinkToPdf usages in your codebase
grep -r "using DinkToPdf" --include="*.cs" .
grep -r "SynchronizedConverter\|HtmlToPdfDocument\|ObjectSettings" --include="*.cs" .

# Find NuGet package references
grep -r "DinkToPdf" --include="*.csproj" .

# Find wkhtmltopdf binaries
find . -name "libwkhtmltox*"
# Find all DinkToPdf usages in your codebase
grep -r "using DinkToPdf" --include="*.cs" .
grep -r "SynchronizedConverter\|HtmlToPdfDocument\|ObjectSettings" --include="*.cs" .

# Find NuGet package references
grep -r "DinkToPdf" --include="*.csproj" .

# Find wkhtmltopdf binaries
find . -name "libwkhtmltox*"
SHELL

Breaking Changes to Anticipate

ChangeDinkToPdfIronPDFImpact
ConverterSynchronizedConverter(new PdfTools())ChromePdfRendererSimpler instantiation
DocumentHtmlToPdfDocumentDirect method callNo document object
SettingsGlobalSettings + ObjectSettingsRenderingOptionsSingle options object
Return typebyte[]PdfDocumentMore powerful object
Binarylibwkhtmltox.dll/soNone (managed)Remove native files
Thread safetySynchronizedConverter requiredThread-safe by defaultSimpler code
DISingleton requiredAny lifetimeFlexible

Step-by-Step Migration Process

Step 1: Update NuGet Packages

Remove DinkToPdf and install IronPDF:

# Remove DinkToPdf
dotnet remove package DinkToPdf

# Install IronPDF
dotnet add package IronPdf
# Remove DinkToPdf
dotnet remove package DinkToPdf

# Install IronPDF
dotnet add package IronPdf
SHELL

Step 2: Remove Native Binaries

Delete these platform-specific files from your project:

  • libwkhtmltox.dll (Windows)
  • libwkhtmltox.so (Linux)
  • libwkhtmltox.dylib (macOS)

IronPDF has no native dependencies—everything is managed code.

Step 3: Update Namespace References

Replace DinkToPdf namespaces with IronPDF:

// Remove these
using DinkToPdf;
using DinkToPdf.Contracts;

// Add this
using IronPdf;
// Remove these
using DinkToPdf;
using DinkToPdf.Contracts;

// Add this
using IronPdf;
$vbLabelText   $csharpLabel

Step 4: Configure License

// Add at application startup (Program.cs or Global.asax)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Global.asax)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
$vbLabelText   $csharpLabel

Complete API Migration Reference

Core Class Mapping

DinkToPdfIronPDFNotes
SynchronizedConverterChromePdfRendererThread-safe by default
BasicConverterChromePdfRendererSame class, simpler
PdfToolsNot neededInternalized
HtmlToPdfDocumentNot neededDirect method calls
GlobalSettingsRenderingOptionsPart of renderer
ObjectSettingsRenderingOptionsPart of renderer
MarginSettingsIndividual margin propertiesMarginTop, MarginBottom, etc.

GlobalSettings Mapping

DinkToPdf GlobalSettingsIronPDF Equivalent
ColorMode = ColorMode.ColorDefault (always color)
Orientation = Orientation.PortraitPaperOrientation = PdfPaperOrientation.Portrait
Orientation = Orientation.LandscapePaperOrientation = PdfPaperOrientation.Landscape
PaperSize = PaperKind.A4PaperSize = PdfPaperSize.A4
Margins = new MarginSettings()Individual margin properties

MarginSettings Mapping

DinkToPdf MarginsIronPDF Equivalent
Margins.Top = 10MarginTop = 10
Margins.Bottom = 10MarginBottom = 10
Margins.Left = 15MarginLeft = 15
Margins.Right = 15MarginRight = 15

Code Migration Examples

Basic HTML to PDF

The fundamental conversion demonstrates the dramatic simplification from DinkToPdf's verbose configuration to IronPDF's streamlined API.

DinkToPdf Implementation:

// NuGet: Install-Package DinkToPdf
using DinkToPdf;
using DinkToPdf.Contracts;
using System.IO;

class Program
{
    static void Main()
    {
        var converter = new SynchronizedConverter(new PdfTools());
        var doc = new HtmlToPdfDocument()
        {
            GlobalSettings = {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize = PaperKind.A4,
            },
            Objects = {
                new ObjectSettings() {
                    HtmlContent = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>",
                    WebSettings = { DefaultEncoding = "utf-8" }
                }
            }
        };
        byte[] pdf = converter.Convert(doc);
        File.WriteAllBytes("output.pdf", pdf);
    }
}
// NuGet: Install-Package DinkToPdf
using DinkToPdf;
using DinkToPdf.Contracts;
using System.IO;

class Program
{
    static void Main()
    {
        var converter = new SynchronizedConverter(new PdfTools());
        var doc = new HtmlToPdfDocument()
        {
            GlobalSettings = {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize = PaperKind.A4,
            },
            Objects = {
                new ObjectSettings() {
                    HtmlContent = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>",
                    WebSettings = { DefaultEncoding = "utf-8" }
                }
            }
        };
        byte[] pdf = converter.Convert(doc);
        File.WriteAllBytes("output.pdf", pdf);
    }
}
$vbLabelText   $csharpLabel

IronPDF Implementation:

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

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

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

IronPDF reduces a 20-line DinkToPdf configuration to 4 lines. No SynchronizedConverter, no PdfTools, no HtmlToPdfDocument, no ObjectSettings—just render and save. For more options, see the HTML to PDF documentation.

URL to PDF Conversion

DinkToPdf Implementation:

// NuGet: Install-Package DinkToPdf
using DinkToPdf;
using DinkToPdf.Contracts;
using System.IO;

class Program
{
    static void Main()
    {
        var converter = new SynchronizedConverter(new PdfTools());
        var doc = new HtmlToPdfDocument()
        {
            GlobalSettings = {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize = PaperKind.A4,
            },
            Objects = {
                new ObjectSettings() {
                    Page = "https://www.example.com",
                }
            }
        };
        byte[] pdf = converter.Convert(doc);
        File.WriteAllBytes("webpage.pdf", pdf);
    }
}
// NuGet: Install-Package DinkToPdf
using DinkToPdf;
using DinkToPdf.Contracts;
using System.IO;

class Program
{
    static void Main()
    {
        var converter = new SynchronizedConverter(new PdfTools());
        var doc = new HtmlToPdfDocument()
        {
            GlobalSettings = {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Portrait,
                PaperSize = PaperKind.A4,
            },
            Objects = {
                new ObjectSettings() {
                    Page = "https://www.example.com",
                }
            }
        };
        byte[] pdf = converter.Convert(doc);
        File.WriteAllBytes("webpage.pdf", pdf);
    }
}
$vbLabelText   $csharpLabel

IronPDF Implementation:

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

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;
using System;

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

IronPDF's RenderUrlAsPdf replaces the nested ObjectSettings.Page configuration with a direct method call. For more options, see the URL to PDF documentation.

Custom Settings with Landscape and Margins

DinkToPdf Implementation:

// NuGet: Install-Package DinkToPdf
using DinkToPdf;
using DinkToPdf.Contracts;
using System.IO;

class Program
{
    static void Main()
    {
        var converter = new SynchronizedConverter(new PdfTools());
        var doc = new HtmlToPdfDocument()
        {
            GlobalSettings = {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Landscape,
                PaperSize = PaperKind.A4,
                Margins = new MarginSettings { Top = 10, Bottom = 10, Left = 15, Right = 15 }
            },
            Objects = {
                new ObjectSettings() {
                    HtmlContent = "<h1>Custom PDF</h1><p>Landscape orientation with custom margins.</p>",
                    WebSettings = { DefaultEncoding = "utf-8" }
                }
            }
        };
        byte[] pdf = converter.Convert(doc);
        File.WriteAllBytes("custom.pdf", pdf);
    }
}
// NuGet: Install-Package DinkToPdf
using DinkToPdf;
using DinkToPdf.Contracts;
using System.IO;

class Program
{
    static void Main()
    {
        var converter = new SynchronizedConverter(new PdfTools());
        var doc = new HtmlToPdfDocument()
        {
            GlobalSettings = {
                ColorMode = ColorMode.Color,
                Orientation = Orientation.Landscape,
                PaperSize = PaperKind.A4,
                Margins = new MarginSettings { Top = 10, Bottom = 10, Left = 15, Right = 15 }
            },
            Objects = {
                new ObjectSettings() {
                    HtmlContent = "<h1>Custom PDF</h1><p>Landscape orientation with custom margins.</p>",
                    WebSettings = { DefaultEncoding = "utf-8" }
                }
            }
        };
        byte[] pdf = converter.Convert(doc);
        File.WriteAllBytes("custom.pdf", pdf);
    }
}
$vbLabelText   $csharpLabel

IronPDF Implementation:

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

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
        renderer.RenderingOptions.MarginTop = 10;
        renderer.RenderingOptions.MarginBottom = 10;
        renderer.RenderingOptions.MarginLeft = 15;
        renderer.RenderingOptions.MarginRight = 15;

        var pdf = renderer.RenderHtmlAsPdf("<h1>Custom PDF</h1><p>Landscape orientation with custom margins.</p>");
        pdf.SaveAs("custom.pdf");
    }
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;

class Program
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();
        renderer.RenderingOptions.PaperOrientation = PdfPaperOrientation.Landscape;
        renderer.RenderingOptions.MarginTop = 10;
        renderer.RenderingOptions.MarginBottom = 10;
        renderer.RenderingOptions.MarginLeft = 15;
        renderer.RenderingOptions.MarginRight = 15;

        var pdf = renderer.RenderHtmlAsPdf("<h1>Custom PDF</h1><p>Landscape orientation with custom margins.</p>");
        pdf.SaveAs("custom.pdf");
    }
}
$vbLabelText   $csharpLabel

IronPDF's RenderingOptions replaces both GlobalSettings and MarginSettings with a unified, fluent API. For more configuration options, see the rendering options documentation.

Critical Migration Notes

Remove Native Binaries

The most important cleanup step is removing wkhtmltopdf native binaries. IronPDF has no native dependencies:

# Delete native binaries
rm libwkhtmltox.* 2>/dev/null
# Delete native binaries
rm libwkhtmltox.* 2>/dev/null
SHELL

No Singleton Required

DinkToPdf's SynchronizedConverter had to be registered as a singleton to avoid crashes. IronPDF's ChromePdfRenderer is thread-safe with any DI lifetime:

// DinkToPdf - MUST be singleton
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));

// IronPDF - any lifetime works
services.AddScoped<ChromePdfRenderer>();
// Or just create inline:
var renderer = new ChromePdfRenderer();
// DinkToPdf - MUST be singleton
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));

// IronPDF - any lifetime works
services.AddScoped<ChromePdfRenderer>();
// Or just create inline:
var renderer = new ChromePdfRenderer();
$vbLabelText   $csharpLabel

Richer Return Type

DinkToPdf returns byte[]. IronPDF returns PdfDocument with manipulation capabilities:

// DinkToPdf returns byte[]
byte[] pdf = converter.Convert(doc);
File.WriteAllBytes("output.pdf", pdf);
return File(pdf, "application/pdf");

// IronPDF returns PdfDocument
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
return File(pdf.BinaryData, "application/pdf");
// DinkToPdf returns byte[]
byte[] pdf = converter.Convert(doc);
File.WriteAllBytes("output.pdf", pdf);
return File(pdf, "application/pdf");

// IronPDF returns PdfDocument
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
return File(pdf.BinaryData, "application/pdf");
$vbLabelText   $csharpLabel

Full CSS3 Support

Modern layouts that fail in DinkToPdf work perfectly in IronPDF:

// DinkToPdf - doesn't work (wkhtmltopdf uses 2015 WebKit)
var html = "<div style='display: flex;'>...</div>";  // Broken!

// IronPDF - full support (modern Chromium)
var html = @"
    <div style='display: flex; justify-content: space-between;'>
        <div>Left</div>
        <div>Right</div>
    </div>";
var pdf = renderer.RenderHtmlAsPdf(html);  // Works!
// DinkToPdf - doesn't work (wkhtmltopdf uses 2015 WebKit)
var html = "<div style='display: flex;'>...</div>";  // Broken!

// IronPDF - full support (modern Chromium)
var html = @"
    <div style='display: flex; justify-content: space-between;'>
        <div>Left</div>
        <div>Right</div>
    </div>";
var pdf = renderer.RenderHtmlAsPdf(html);  // Works!
$vbLabelText   $csharpLabel

Post-Migration Checklist

After completing the code migration, verify the following:

  • Run all unit tests to verify PDF generation works correctly
  • Test multi-threaded scenarios (these crashed with DinkToPdf)
  • Compare PDF output quality (IronPDF's Chromium renders better)
  • Verify CSS rendering (Flexbox/Grid now works)
  • Test JavaScript execution (reliable with IronPDF)
  • Update CI/CD pipelines to remove wkhtmltopdf installation
  • Verify security scan passes (no more CVE-2022-35583 flags)
  • Remove native binary deployment from Docker/deployment scripts

Future-Proofing Your PDF Infrastructure

With .NET 10 on the horizon and C# 14 introducing new language features, choosing a PDF library that's actively maintained ensures long-term compatibility. IronPDF's modern Chromium engine receives regular updates, while DinkToPdf's abandoned wkhtmltopdf remains frozen at 2015 capabilities—a growing gap that will only widen as web standards evolve through 2025 and 2026.

Additional Resources


Migrating from DinkToPdf to IronPDF eliminates critical security vulnerabilities (CVE-2022-35583), thread safety crashes, native binary deployment complexity, and outdated CSS rendering. The transition to a modern Chromium engine delivers full CSS3 support, reliable JavaScript execution, and the peace of mind that comes with an actively maintained library.

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