Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Choosing the right PDF library for your needs can be difficult when there are seemingly countless PDF libraries out there to choose from. When comparing different PDF libraries, there are a few things to keep in mind, such as; What features does the library have to offer? Do the features cover your needs, or can it only do half of what you need? What level of support and documentation does the library have to offer? Is there much of a learning curve? And what about pricing? Is the licensing price within your budget?
Today, we will be taking a look at two powerful PDF generation libraries: IronPDF and WkHtmlToPdf. Each library brings its unique strengths to the table, offering solutions for different PDF generation and manipulation needs.
IronPDF is a robust C# library that facilitates seamless PDF creation, manipulation, and processing within the .NET framework. With a user-friendly API and extensive support for a wide range of PDF-related functionalities, IronPDF makes it easier for developers to integrate PDF functionalities into C# applications. The library is known for its comprehensive feature set, including HTML to PDF conversion, text and image extraction, form handling, and document security options like encryption and digital signatures. You can easily install IronPDF via the NuGet Package Manager Console, and get the library running in no time. For more information, visit IronPDF's official website.
WkHtmlToPdf is a .NET Core P/Invoke wrapper for the WkHtmlToPdf library, a popular tool for converting HTML pages to PDF using the Qt Webkit rendering engine. This open-source library is forked from DinkToPdf and offers basic HTML to PDF conversion features with a focus on simplicity and efficiency. Its easy to install, after downloading and running the WkHtmlToPdf executable, all you need to do is ensure that it is added to your system's path environment variable. While lacking in the advanced features that IronPDF has to offer, WkHtmlToPdf is a lightweight and easy to use library.
IronPDF stands out with its extensive cross-platform compatibility. It supports a wide range of environments within the .NET framework, ensuring seamless operation across different platforms.
.NET versions:
Fully written in and supports C#, VB.NET, and F#
.NET Core (8, 7, 6, 5, and 3.1+)
.NET Standard (2.0+)
App environments: IronPDF works within various app environments such as Windows, Linux, Mac, Docker, Azure, and AWS.
IDEs: Works with IDEs such as Microsoft Visual Studio and JetBrains Rider & ReSharper
For more details on IronPDF's compatibility, visit IronPDF Compatibility.
.NET versions: As a command-line tool, WkHtmlToPdf itself doesn't have direct .NET support, however .NET developers typically interact with it using a wrapper or library, such as DinkToPdf.
.App Environments: WkHtmlToPdf works smoothly within several app environments such as Windows, Linux, and macOS.
When comparing IronPDF and WkHtmlToPdf, it's essential to look at the features both libraries provide for PDF generation and manipulation.
PDF conversion: IronPDF can convert HTML to PDF, with its full support for modern web standards, you can be assured that IronPDF will consistently return pixel-perfect PDFs from your HTML page, file, or content. IronPDF can also convert PDF files from other formats such as DOCX, images, RTF, and more.
PDF Generation: With IronPDF, you can generate PDFs from URLs, image formats, ASPX files, or HTML strings.
Security features: With IronPDF, you can always be assured that any sensitive PDF files are secure thanks to its security features. Use IronPDF to encrypt your PDF files, set passwords, and set permissions for your PDF files.
For more details on IronPDF features, visit IronPDF Features.
HTML to PDF Conversion: Convert HTML pages, files, strings, and CSS content to PDF, retaining the original layout.
Customization Options: Supports page size, margins, headers, footers, etc.
Open Source: Free to use under the MIT license.
IronPDF:
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
Imports IronPdf
' Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = True
' Instantiate Renderer
Dim renderer = New ChromePdfRenderer()
' Create a PDF from an HTML string using C#
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
' Export to a file or Stream
pdf.SaveAs("output.pdf")
' Advanced Example with HTML Assets
' Load external html assets: Images, CSS and JavaScript.
' An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
Dim myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
myAdvancedPdf.SaveAs("html-with-assets.pdf")
WkHtmlToPdf (Using DinkToPdf):
using DinkToPdf;
var converter = new BasicConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
Objects = { new ObjectSettings() { HtmlContent = "<h1>Hello World</h1>" } }
};
byte[] pdf = converter.Convert(doc);
System.IO.File.WriteAllBytes("HtmlToPdf.pdf", pdf);
using DinkToPdf;
var converter = new BasicConverter(new PdfTools());
var doc = new HtmlToPdfDocument()
{
Objects = { new ObjectSettings() { HtmlContent = "<h1>Hello World</h1>" } }
};
byte[] pdf = converter.Convert(doc);
System.IO.File.WriteAllBytes("HtmlToPdf.pdf", pdf);
Imports DinkToPdf
Private converter = New BasicConverter(New PdfTools())
Private doc = New HtmlToPdfDocument() With {
.Objects = {
New ObjectSettings() With {.HtmlContent = "<h1>Hello World</h1>"}
}
}
Private pdf() As Byte = converter.Convert(doc)
System.IO.File.WriteAllBytes("HtmlToPdf.pdf", pdf)
WkHtmlToPdf (Using command line)
wkhtmltopdf myfile.html myfile.pdf
wkhtmltopdf myfile.html myfile.pdf
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'wkhtmltopdf myfile.html myfile.pdf
With IronPDF, you can create pixel-perfect PDF files from HTML content in just a few lines of code! Its support for modern web standards ensures the PDF file you produce retain as much of the original source's quality as possible. WkHtmlToPdf is built around HTML to PDF conversion, and its simplistic way of tackling this task, whether as part of another library or within a command line tool, just goes to show this.
IronPDF:
using IronPdf;
using System;
//Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
//Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
//Edit file security settings
//The following code makes a PDF read only and will disallow copy & paste and printing
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
using IronPdf;
using System;
//Open an Encrypted File, alternatively create a new PDF from Html
var pdf = PdfDocument.FromFile("encrypted.pdf", "password");
//Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto";
pdf.MetaData.Keywords = "SEO, Friendly";
pdf.MetaData.ModifiedDate = DateTime.Now;
//Edit file security settings
//The following code makes a PDF read only and will disallow copy & paste and printing
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights;
// change or set the document encryption password
pdf.Password = "my-password";
pdf.SaveAs("secured.pdf");
Imports IronPdf
Imports System
'Open an Encrypted File, alternatively create a new PDF from Html
Private pdf = PdfDocument.FromFile("encrypted.pdf", "password")
'Edit file metadata
pdf.MetaData.Author = "Satoshi Nakamoto"
pdf.MetaData.Keywords = "SEO, Friendly"
pdf.MetaData.ModifiedDate = DateTime.Now
'Edit file security settings
'The following code makes a PDF read only and will disallow copy & paste and printing
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = IronPdf.Security.PdfPrintSecurity.FullPrintRights
' change or set the document encryption password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")
WkHtmlToPdf:
Encryption support is not directly provided by WkHtmlToPdf without third-party libraries.
IronPDF provides a straightforward, easy-to-implement method for encrypting PDF files, while giving you plenty of control of the entire process. WkHtmlToPdf, due to it being more of HTML to PDF conversion focused tool, doesn't offer any direct support for PDF encryption on its own.
IronPDF:
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");
// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");
pdf.SaveAs("redacted.pdf");
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")
' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")
pdf.SaveAs("redacted.pdf")
WkHtmlToPdf:
WkHtmlToPdf lacks built-in redaction features.
IronPDF's redaction feature is a powerful, concise API that makes it easy to redact specified content in just a few lines of code, making the automation of your redaction tasks easy. WkHtmlToPdf does not offer any built-in support for PDF redaction.
IronPDF:
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;
// Instantiate Renderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>foo</h1>");
// Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
X509Certificate2 cert = new X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable);
// Create PdfSignature object
var sig = new PdfSignature(cert);
// Sign PDF document
pdf.Sign(sig);
pdf.SaveAs("signed.pdf");
Imports IronPdf
Imports IronPdf.Signing
Imports System.Security.Cryptography.X509Certificates
' Instantiate Renderer
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>foo</h1>")
' Create X509Certificate2 object with X509KeyStorageFlags set to Exportable
Private cert As New X509Certificate2("IronSoftware.pfx", "123456", X509KeyStorageFlags.Exportable)
' Create PdfSignature object
Private sig = New PdfSignature(cert)
' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
WkHtmlToPdf C#:
WkHtmlToPdf C# does not offer native support for signing PDFs.
When you're using IronPDF, its easy to digitally sign your PDF thanks to its easy-to-use digital signature feature. This powerful signing tool gives you the tools you need to start digitally signing PDF files programmatically, saving you time if you find yourself signing PDF files regularly. With WkHtmlToPdf, it in itself cannot handle PDF signing, however if you're using it as a part of another library, that library may have the capabilities to carry out this task.
IronPDF:
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
using IronPdf;
// Stamps a Watermark onto a new or existing PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center);
pdf.SaveAs(@"C:\Path\To\Watermarked.pdf");
Imports IronPdf
' Stamps a Watermark onto a new or existing PDF
Private renderer = New ChromePdfRenderer()
Private pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
pdf.ApplyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, IronPdf.Editing.VerticalAlignment.Middle, IronPdf.Editing.HorizontalAlignment.Center)
pdf.SaveAs("C:\Path\To\Watermarked.pdf")
WkHtmlToPdf:
Does not have a direct, clear method for this. Instead, you would need to implement advanced CSS styling in order to apply watermarks, or use a separate PDF library that can handle it.
IronPDF provides users with a strong, concise watermarking tool. With an approach similar to HTML/CSS, IronPDF's watermarking tool is easy to use and makes applying your custom watermarks to PDF files a breeze. If you're using WkHtmlToPdf by itself, watermarking is only possible with the use of CSS.
IronPDF:
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
using IronPdf;
using IronPdf.Editing;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create text stamper
TextStamper textStamper = new TextStamper()
{
Text = "Text Stamper!",
FontFamily = "Bungee Spice",
UseGoogleFont = true,
FontSize = 30,
IsBold = true,
IsItalic = true,
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the text stamper
pdf.ApplyStamp(textStamper);
pdf.SaveAs("stampText.pdf");
Imports IronPdf
Imports IronPdf.Editing
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create text stamper
Private textStamper As New TextStamper() With {
.Text = "Text Stamper!",
.FontFamily = "Bungee Spice",
.UseGoogleFont = True,
.FontSize = 30,
.IsBold = True,
.IsItalic = True,
.VerticalAlignment = VerticalAlignment.Top
}
' Stamp the text stamper
pdf.ApplyStamp(textStamper)
pdf.SaveAs("stampText.pdf")
using IronPdf;
using IronPdf.Editing;
using System;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");
using IronPdf;
using IronPdf.Editing;
using System;
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>");
// Create image stamper
ImageStamper imageStamper = new ImageStamper(new Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg"))
{
VerticalAlignment = VerticalAlignment.Top,
};
// Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0);
pdf.SaveAs("stampImage.pdf");
Imports IronPdf
Imports IronPdf.Editing
Imports System
Private renderer As New ChromePdfRenderer()
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Example HTML Document!</h1>")
' Create image stamper
Private imageStamper As New ImageStamper(New Uri("https://ironpdf.com/img/svgs/iron-pdf-logo.svg")) With {.VerticalAlignment = VerticalAlignment.Top}
' Stamp the image stamper
pdf.ApplyStamp(imageStamper, 0)
pdf.SaveAs("stampImage.pdf")
WkHtmlToPdf C#:
Stamping text and images requires an indirect approach using HTML and CSS, as it does not have any built-in options specifically for this.
With IronPDF, Stamping Text and Images onto your PDF files has never been easier thanks to its powerful, yet easy-to-use image and text stamping tools. WkHtmlToPdf doesn't contain any built-in stamping tools, but you can still achieve a similar result by using HTML and CSS to apply the stamped content.
IronPDF:
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
using IronPdf;
// Instantiate Renderer
DocxToPdfRenderer renderer = new DocxToPdfRenderer();
// Render from DOCX file
PdfDocument pdf = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx");
// Save the PDF
pdf.SaveAs("pdfFromDocx.pdf");
Imports IronPdf
' Instantiate Renderer
Private renderer As New DocxToPdfRenderer()
' Render from DOCX file
Private pdf As PdfDocument = renderer.RenderDocxAsPdf("Modern-chronological-resume.docx")
' Save the PDF
pdf.SaveAs("pdfFromDocx.pdf")
WkHtmlToPdf C#:
Requires additional libraries to handle DOCX to PDF conversions.
IronPDF simplifies DOCX to PDF conversion with its powerful DOCX to PDF tool, while taking only a few lines of code, ultimately raising the efficiency of your projects. WkHtmlToPdf doesn't offer any built-in DOCX to PDF conversion support, instead you would need to look into other PDF libraries that can handle it.
To learn more about the rich set of features IronPDF has to offer, and see them in action, check out the IronPDF how-to guides which takes a deep dive into each feature, explore how they work and give you the skills you need to be a PDF pro.
IronPDF has different levels and additional features for purchasing a license. Developers can also buy IronSuite which gives you access to all of IronSoftware’s products at the price of two. If you’re not ready to buy a license, IronPDF provides a free trial so you can explore all the features it has to offer before committing to a license.
Perpetual licenses: Offers a range of perpetual licenses depending on the size of your team, your project needs, and the number of locations. Each license type comes with email support.
Lite License: This license costs $749 and supports one developer, one location, and one project.
Plus License: Supporting three developers, three locations, and three projects, this is the next step up from the lite license and costs $1,499. The Plus license offers chat support and phone support in addition to basic email support.
Professional License: This license is suitable for larger teams, supporting ten developers, ten locations, and ten projects for $2,999. It offers the same contact support channels as the previous tiers but also offers screen-sharing support.
Royalty-free redistribution: IronPDF's licensing also offers royalty-free redistribution coverage for an extra $1,999
Uninterrupted product support: IronPDF offers access to ongoing product updates, security feature upgrades, and support from their engineering team for either $999/year or a one-time purchase of $1,999 for a 5-year coverage.
WkHtmlToPdf is a free-to-use open source tool, licensed under the LGPL License which allows you to use wkhtmltopdf in proprietary applications as long as you do not modify the library itself.
IronPDF excels in providing extensive documentation and support:
Comprehensive Documentation: Extensive and user-friendly documentation covering all features.
24/5 Support: Active engineer support is available.
Video Tutorials: Step-by-step video guides are available on YouTube.
Community Forum: Engaged community for additional support.
Regular Updates: Monthly product updates to ensure the latest features and security patches.
For more information, check out IronPDF's extensive documentation, and visit the IronSoftware YouTube Channel.
GitHub: WkHtmlToPdf's GitHub repository is a place where users can report issues they find while using the tool.
Stack overflow: Here, You can find numerous questions and answers related to WkHtmlToPdf, and get community advice.
In conclusion, both IronPDF and WkHtmlToPdf offer unique strengths for PDF generation and manipulation in C#. IronPDF stands out with its comprehensive feature set, including advanced PDF functionalities such as encryption, redaction, digital signing, and seamless DOCX to PDF conversion, making it a robust solution for developers looking for a versatile and easy-to-use library. Between its rich feature set and extensive documentation, IronPDF is a powerful tool to have in your developers toolkit if you work with PDF files regularly.
On the other hand, WkHtmlToPdf excels in simplicity and efficiency for HTML to PDF conversions, particularly for users seeking a lightweight, open-source solution without advanced PDF manipulation capabilities. While it lacks some of the more sophisticated features of IronPDF, WkHtmlToPdf's ease of use, cross-platform support, and zero cost make it an appealing choice for basic PDF generation tasks. Ultimately, the choice between IronPDF and WkHtmlToPdf will depend on the specific requirements of your project, the need for advanced PDF features, and your budget considerations.
You can try the 30-day free trial to check out their available features.
9 .NET API products for your office documents