Skip to footer content
USING IRONPDF

HtmlToPdfDocument C# - DinkToPdf Alternative | IronPDF

If you're working with HtmlToPdfDocument C# in DinkToPdf and experiencing limited CSS support, external dependencies, or performance issues, you're not alone. Many .NET developers seek an HTML to PDF converter that handles modern CSS, web fonts, and JavaScript execution without native library setup or command line tools. This guide shows you how to replace DinkToPdf with IronPDF -- a .NET library with a Chromium-based rendering engine that converts HTML files, web pages, and HTML strings to high-quality PDFs in just a few lines of code.

  1. Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf
  2. Copy and run this code snippet.

    IronPdf.ChromePdfRenderer
           .StaticRenderHtmlAsPdf("<h1>Hello World</h1>")
           .SaveAs("output.pdf");
  3. Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial

    arrow pointer

How Do You Install IronPDF via NuGet?

Before writing any conversion code, you need to add IronPDF to your project. The fastest path is the NuGet Package Manager CLI:

dotnet add package IronPdf
dotnet add package IronPdf
SHELL

Alternatively, open the NuGet Package Manager Console in Visual Studio and run:

Install-Package IronPdf
Install-Package IronPdf
SHELL

IronPDF targets .NET 8, .NET 9, .NET 10, .NET Standard 2.0, and .NET Framework 4.6.2 or higher. No additional native binaries, wkhtmltopdf installations, or command line tool setup is required. The package bundles the Chromium rendering engine and resolves all dependencies automatically. Once installed, you can set your license key in code or via an environment variable and start generating PDFs immediately. For detailed installation guidance, the IronPDF getting started page walks through every environment.

How Does DinkToPdf Compare to IronPDF?

DinkToPdf is a .NET Core wrapper for wkhtmltopdf, using the older WebKit rendering engine. While open-source, developers often face challenges when converting HTML to PDF in production environments.

DinkToPdf vs IronPDF feature comparison
Feature DinkToPdf IronPDF
Rendering Engine WebKit (outdated) Chromium (modern)
CSS Support Limited CSS support Full CSS3, modern CSS
JavaScript Execution Limited Full JavaScript rendering
Native Dependencies Requires wkhtmltopdf binaries No external dependencies
Web Fonts Partial Complete support
.NET Core / .NET 5+ Yes Yes (.NET Core, Framework, Standard)
Azure App Service Complex setup Works out of the box
Threading Singleton required Thread-safe
HTML Templates Basic Advanced features
Fillable PDF Forms No Yes

The core difference lies in the rendering engine. DinkToPdf's WebKit engine struggles with complex documents, modern CSS, and dynamic web content. IronPDF's Chromium engine produces PDF documents that match exactly what a browser renders. For a deeper breakdown, see the IronPDF vs DinkToPdf comparison page.

What Problems Does DinkToPdf's HtmlToPdfDocument Class Present?

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 1 - DinkToPdf

The HtmlToPdfDocument class in DinkToPdf requires verbose configuration with limitations that affect PDF conversion quality and developer experience:

using DinkToPdf;

var converter = new SynchronizedConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
    GlobalSettings = { PaperSize = PaperKind.A4, Out = "output.pdf" },
    Objects = { new ObjectSettings() { HtmlContent = "<h1>Hello</h1>" } }
};
converter.Convert(doc);
using DinkToPdf;

var converter = new SynchronizedConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
    GlobalSettings = { PaperSize = PaperKind.A4, Out = "output.pdf" },
    Objects = { new ObjectSettings() { HtmlContent = "<h1>Hello</h1>" } }
};
converter.Convert(doc);
$vbLabelText   $csharpLabel

DinkToPdf PDF Output

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 2 - DinkToPdf example output PDF

Common issues include: slow PDF generation for even simple tasks, threading complications on web servers, and difficulty handling web content with JavaScript. The wkhtmltopdf command line tool creates deployment challenges for Azure App Service and serverless environments where you cannot install system-level binaries. Developers also report that the singleton converter pattern becomes a bottleneck under concurrent load.

Beyond performance, the DinkToPdf project on GitHub shows limited maintenance activity, meaning bugs in CSS rendering or SSL handling rarely receive fixes. For production applications that process thousands of PDFs daily, these gaps are not acceptable. When a CSS Grid layout breaks or a web font fails to load, you need a library that tracks modern browser behavior, not one frozen in time with a rendering engine from the early 2010s.

How Do You Convert an HTML String to PDF with IronPDF?

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 3 - IronPDF

IronPDF simplifies HTML to PDF conversion with a cleaner API and superior output quality. The ChromePdfRenderer handles all HTML content -- from a simple HTML string to complex HTML pages with external stylesheets, Google Fonts, and JavaScript-driven layouts.

using IronPdf;

var renderer = new ChromePdfRenderer();

string htmlContent = @"
    <!DOCTYPE html>
    <html>
    <head>
        <style>
            body { font-size: 14px; text-align: center; }
            h1 { color: #2563eb; }
        </style>
    </head>
    <body>
        <h1>Professional Invoice</h1>
        <p>Generated with modern CSS support</p>
    </body>
    </html>";

var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("invoice.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

string htmlContent = @"
    <!DOCTYPE html>
    <html>
    <head>
        <style>
            body { font-size: 14px; text-align: center; }
            h1 { color: #2563eb; }
        </style>
    </head>
    <body>
        <h1>Professional Invoice</h1>
        <p>Generated with modern CSS support</p>
    </body>
    </html>";

var pdf = renderer.RenderHtmlAsPdf(htmlContent);
pdf.SaveAs("invoice.pdf");
$vbLabelText   $csharpLabel

IronPDF HTML String Output

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 4 - IronPDF example simple HTML string to PDF output

This code demonstrates how IronPDF processes HTML and CSS during conversion, producing PDF documents with proper font size rendering and text alignment -- all without external dependencies. The RenderHtmlAsPdf method accepts any valid HTML5 string, including inline styles, embedded scripts, and data URIs for images.

How Do You Convert an HTML File to PDF?

For converting HTML files stored on disk:

using IronPdf;

var renderer = new ChromePdfRenderer();
var doc = renderer.RenderHtmlFileAsPdf("templates/input.html");
doc.SaveAs("example.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();
var doc = renderer.RenderHtmlFileAsPdf("templates/input.html");
doc.SaveAs("example.pdf");
$vbLabelText   $csharpLabel

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 5 - Output for HTML file to PDF example

The RenderHtmlFileAsPdf method resolves relative paths for images, stylesheets, and scripts relative to the HTML file's location on disk, so existing templates work without modification. This makes migrating existing report templates straightforward.

How Do You Convert a Web Page URL to PDF?

Converting live web content is where IronPDF excels over DinkToPdf's limited JavaScript rendering. IronPDF's Chromium engine supports dynamic HTML elements, single-page applications, and interactive forms.

using IronPdf;

var renderer = new ChromePdfRenderer();

// Enable JavaScript execution for dynamic content
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.WaitFor.RenderDelay(500);
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

string url = "https://en.wikipedia.org/wiki/Main_Page";
var page = renderer.RenderUrlAsPdf(url);
page.SaveAs("webpage.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

// Enable JavaScript execution for dynamic content
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.WaitFor.RenderDelay(500);
renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;

string url = "https://en.wikipedia.org/wiki/Main_Page";
var page = renderer.RenderUrlAsPdf(url);
page.SaveAs("webpage.pdf");
$vbLabelText   $csharpLabel

Converted URL to PDF

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 6 - Rendered PDF from URL content

This approach is ideal for generating invoices from web forms or archiving live dashboards. The rendering engine processes all web fonts, CSS styles, and JavaScript before producing the PDF file. The WaitFor API gives you precise control over when the Chromium engine considers a page ready for capture -- you can wait for specific DOM elements, network idle states, or custom JavaScript conditions, which is essential for large-scale PDF generation from dynamic content.

For authenticated pages, you can pass HTTP headers, cookies, or form POST data directly to the renderer. The URL to PDF documentation covers these advanced scenarios in detail.

How Do You Configure PDF Output Settings?

Both libraries offer configuration options, but IronPDF provides more intuitive control over the generated PDF through its RenderingOptions object:

using IronPdf;

var renderer = new ChromePdfRenderer();

renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 25;
renderer.RenderingOptions.MarginBottom = 25;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.TextHeader.CenterText = "Company Report";
renderer.RenderingOptions.TextFooter.CenterText = "{page} of {total-pages}";

var document = renderer.RenderHtmlAsPdf("<h1 style='text-align: center;'>Quarterly Report</h1>");
document.SaveAs("configured-report.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4;
renderer.RenderingOptions.MarginTop = 25;
renderer.RenderingOptions.MarginBottom = 25;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;
renderer.RenderingOptions.TextHeader.CenterText = "Company Report";
renderer.RenderingOptions.TextFooter.CenterText = "{page} of {total-pages}";

var document = renderer.RenderHtmlAsPdf("<h1 style='text-align: center;'>Quarterly Report</h1>");
document.SaveAs("configured-report.pdf");
$vbLabelText   $csharpLabel

Output PDF with Custom Settings

HtmlToPdfDocument C#: DinkToPdf Alternative for HTML to PDF Conversion: Image 7 - Customized PDF output

These options control paper size, margins, headers, and footers. IronPDF also supports custom HTML headers and footers that accept full HTML and CSS, letting you place logos, dynamic page counts, and styled text in the header and footer areas. For document security, the PDF encryption and passwords API lets you restrict printing, copying, or editing after generation.

How Do You Merge Multiple PDFs?

When you need to combine multiple HTML documents into one PDF, IronPDF provides a static merge method:

using IronPdf;

var renderer = new ChromePdfRenderer();

var pdf1 = renderer.RenderHtmlAsPdf("<h1>Section One</h1>");
var pdf2 = renderer.RenderHtmlAsPdf("<h1>Section Two</h1>");

var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged-report.pdf");
using IronPdf;

var renderer = new ChromePdfRenderer();

var pdf1 = renderer.RenderHtmlAsPdf("<h1>Section One</h1>");
var pdf2 = renderer.RenderHtmlAsPdf("<h1>Section Two</h1>");

var merged = PdfDocument.Merge(pdf1, pdf2);
merged.SaveAs("merged-report.pdf");
$vbLabelText   $csharpLabel

The PDF merge documentation shows how to assemble large documents from many source files, apply consistent headers and footers across all sections, and reorder pages programmatically. This is useful for report generation pipelines that build individual sections independently before combining them into a single final document.

Why Should You Switch from DinkToPdf to IronPDF?

For developers using HtmlToPdfDocument in .NET Core applications, IronPDF offers key advantages that address each pain point directly:

  • Modern Rendering: Chromium engine handles HTML structure, modern CSS, and JavaScript execution to create pixel-perfect PDF documents
  • Zero Setup: No wkhtmltopdf binaries or command line tool configuration -- just add the NuGet package
  • Better Performance: Faster PDF conversion without singleton threading limitations; the renderer is thread-safe and can run concurrent conversions
  • Full Web Support: Convert HTML with web fonts, CSS animations, SVG graphics, and complex HTML templates
  • Enterprise Deployment: Deploy to Azure App Service, AWS Lambda, Docker containers, and traditional web servers without extra configuration
  • Advanced PDF Features: Fillable PDF forms, digital signatures, PDF/A compliance, and watermarks
  • Active Maintenance: IronPDF releases regular updates tracking the latest Chromium versions and .NET runtimes

According to the Chromium project's release schedule, the engine receives security patches every four weeks. IronPDF bundles updated Chromium builds with each major release, ensuring your PDF generation stays current without any manual binary management. This matters for security-conscious teams that need to demonstrate their dependencies are patched against known vulnerabilities.

The IronPDF documentation library covers more than 50 how-to guides for tasks ranging from splitting PDFs to extracting text and adding annotations.

What Are Your Next Steps?

While DinkToPdf's HtmlToPdfDocument class provides basic HTML to PDF conversion, its outdated WebKit engine and external dependencies create friction for modern .NET development. IronPDF delivers better results with Chromium-based rendering, full CSS support, and zero-dependency deployment. Whether you're building a small internal reporting tool or a high-volume document generation service, the migration path is straightforward: install the NuGet package, replace the DinkToPdf API calls with ChromePdfRenderer equivalents, and remove the wkhtmltopdf binaries from your deployment pipeline.

To move forward, choose the path that fits your situation:

Get stated with IronPDF now.
green arrow pointer

Frequently Asked Questions

What is IronPDF?

IronPDF is a .NET library for converting HTML to PDF using a Chromium rendering engine. It supports modern CSS, JavaScript execution, and web fonts, and requires no native dependencies or external binaries.

Why should I choose IronPDF over DinkToPdf?

IronPDF offers full CSS3 support, no native library or wkhtmltopdf setup, thread-safe concurrent conversions, and straightforward deployment to Azure App Service and Docker -- addressing all major pain points of DinkToPdf.

How does IronPDF improve performance in HTML to PDF conversion?

IronPDF uses a Chromium rendering engine that processes HTML, CSS, and JavaScript efficiently. Its thread-safe design eliminates the singleton bottleneck that affects DinkToPdf under concurrent load.

Does IronPDF support modern web fonts?

Yes. IronPDF's Chromium engine fully supports Google Fonts, system fonts, and custom web fonts embedded in HTML, producing accurate font rendering in the output PDF.

Can IronPDF execute JavaScript during PDF conversion?

Yes. Set EnableJavaScript to true on RenderingOptions and use the WaitFor API to control when Chromium considers the page ready, ensuring dynamic content is fully rendered before capture.

What are the dependencies required for using IronPDF?

IronPDF requires no native dependencies. Install it via NuGet and the package manages the Chromium engine internally. No wkhtmltopdf binaries or command line tools are needed.

Is full CSS support available in IronPDF?

Yes. IronPDF supports CSS3, Flexbox, CSS Grid, custom properties, and media queries, enabling accurate rendering of complex HTML documents.

How does IronPDF handle external libraries or tools?

IronPDF does not rely on external libraries or command line tools. Everything is bundled within the NuGet package, simplifying deployment and eliminating compatibility issues.

What rendering engine does IronPDF use?

IronPDF uses a Chromium-based rendering engine, the same engine that powers Google Chrome, providing accurate and high-performance HTML to PDF conversions.

Is IronPDF suitable for .NET developers looking for an HTML to PDF solution?

Yes. IronPDF targets .NET 8, .NET 9, .NET 10, .NET Standard 2.0, and .NET Framework 4.6.2 or higher, making it suitable for modern and legacy .NET applications alike.

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