Skip to footer content
PRODUCT COMPARISONS

SpirePDF C# HTML to PDF Tutorial & Library Comparison

Converting HTML to PDF is a critical requirement for many .NET applications, from generating invoices and reports to creating documentation and eBooks. When choosing between IronPDF and Spire.PDF for your HTML to PDF conversion needs, understanding their strengths, limitations, and real-world performance becomes essential. This comprehensive comparison examines both libraries' capabilities, helping you make an informed decision for your PDF generation requirements.

What Are the Key Differences Between IronPDF and Spire.PDF for HTML to PDF Conversion?

IronPDF is a versatile .NET PDF library designed to handle a wide range of PDF-related tasks, including converting PDF files, PDF editing, PDF creation, reading PDF files, and more. It is known for its ease of integration into existing .NET applications, high performance, and support for modern web standards like HTML5, CSS3, and JavaScript. IronPDF's Chrome-based rendering engine ensures pixel-perfect PDF generation from HTML content.

Spire.PDF for .NET is another powerful .NET PDF library that provides a comprehensive set of features for PDF creation and manipulation. It supports various PDF functionalities such as text and image extraction, PDF form filling, and digital signatures. While comprehensive in features, its HTML to PDF conversion capabilities have specific limitations that developers should consider.

Product Comparison Overview
Comparison of IronPDF and Spire.PDF Features for .NET PDF Processing
Category Feature/Aspect IronPDF Spire.PDF Key Advantage
Core Architecture Design Philosophy Simplicity-first, intuitive APIs Multi-class approach, manual setup IronPDF: Faster development
API Complexity Simple methods like RenderHtmlAsPdf() Multi-threaded approach required IronPDF: 70% less code
Learning Curve 1–2 days typical 1–2 weeks typical IronPDF: Quicker adoption
Platform Support Cross-Platform Native support, no extra packages Limited Linux/macOS support IronPDF: True cross-platform
.NET Versions .NET 8, 7, 6, 5, Core 3.1+, Framework 4.6.2+ .NET Core 2.0+, Framework 2.0+ Both: Wide framework support
Operating Systems Windows, Linux, macOS, Docker native Primarily Windows-focused IronPDF: Broader OS support
HTML to PDF Rendering Engine Full Chrome V8 engine Custom HTML parser IronPDF: 98%+ browser fidelity
CSS3/HTML5 Support Complete support Limited (basic CSS only) IronPDF: Modern web standards
JavaScript Execution Full JavaScript support Planned but not implemented IronPDF: Dynamic content ready
Web Fonts Google Fonts, system fonts Limited font support IronPDF: Typography flexibility
Rendering Speed 0.8–1.2s typical 0.5–0.8s for simple HTML Spire: Faster for basic HTML
Security & Encryption Encryption Levels AES-256, custom handlers AES-256 standard Both: Industry standard
API Simplicity Single SecuritySettings class Multiple security methods IronPDF: Unified approach
Content Manipulation Redaction Method True content removal, one-line API Manual rectangle overlay IronPDF: Compliance-ready
Watermarking HTML/CSS based, full styling Text-based with rotation IronPDF: Rich watermarks
File Conversions DOCX to PDF Built-in DocxToPdfRenderer Requires Spire.Doc library IronPDF: No extra cost
Performance Metrics Memory Usage 150–200MB (Chrome engine) 80–120MB Spire: Lower memory footprint
Threading Support Native async/await optimized STA thread required IronPDF: Modern async patterns
Developer Experience Code Examples 100+ ready-to-run samples Basic examples IronPDF: Extensive resources
Error Messages Descriptive, actionable Technical messages IronPDF: Better debugging
Licensing & Pricing Entry Level Lite: $749 (1 dev, 1 project) Developer: $999/year (1 dev) IronPDF: Perpetual license
Team License Plus: $1,499 (3 devs, 3 projects) Site: $4,599 (10 devs) IronPDF: Better team value
Suite Option Iron Suite: $1,498 (9 products) No suite option IronPDF: Exceptional value
Support Support Included Yes, 24/5 engineering support Forum only (paid support extra) IronPDF: Support included
Support Channels Email, chat, phone, screen sharing Forum, email (paid tiers) IronPDF: More channels
Best For Use Cases Modern web apps, complex HTML/CSS Simple documents, basic layouts Context-dependent
Note. Spire.PDF offers basic PDF functionality with lower memory usage, while IronPDF excels in HTML rendering and modern web standards support. Select based on whether complex HTML rendering or minimal resource usage is the priority.

For more detailed information about IronPDF, visit IronPDF.com.

How Does Cross-Platform Compatibility Compare Between the Libraries?

IronPDF

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. Below is a summary of IronPDF's platform compatibility:

  • .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+)
    • .NET Framework (4.6.2+)
  • 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
  • OS and Processors: Supports several different OS & processors including Windows, Mac, Linux, x64, x86, ARM

For more details on IronPDF's compatibility, visit the IronPDF Features Page.

Spire.PDF

Spire.PDF has full support within the .NET environment, but while it works within the Windows operating system, it lacks the native support for Linux and macOS that IronPDF has. When deploying on macOS or Linux, Spire.PDF requires different plugins for each platform, which can complicate deployment scenarios.

  • .NET Support:

    • .NET Framework 2.0+
    • .NET Core 2.0+
    • Written in C#, with support for VB.NET
  • App Environments: Spire.PDF works in various app environments such as Windows and ASP.NET applications. It can also support Windows Forms.

Which Library Offers Better HTML to PDF Conversion Features?

IronPDF Features

  • 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 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, 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.
  • PDF editing features: With IronPDF you can process existing PDF documents, edit them, and read PDF files with ease. IronPDF offers editing features such as adding headers and footers, stamping text and images onto the PDF pages, adding custom watermarks to the PDF, working with PDF forms, and splitting or merging PDF files.
  • Integration: Seamlessly integrates with ASP.NET and MVC applications.
  • PDF version support: Can support PDF version 1.2-1.7

For a comprehensive list of IronPDF features, visit IronPDF Features.

Spire.PDF Features

  • PDF Creation: Create PDFs from scratch or existing files.
  • Text and Image Extraction: Use Spire.PDF to extract PDF pages and content.
  • PDF Form Handling: Fill and manage PDF forms.
  • PDF Conversion: Convert PDFs to other formats like HTML, RTF, and images.
  • Page Manipulation: Insert, delete, and reorder pages in a PDF.
  • Limited HTML Support: The HTML to PDF engine has limited support for modern CSS and JavaScript, meaning it struggles with complex styling and dynamic layouts.

How Do Code Examples Compare for Common PDF Tasks?

To illustrate the capabilities of IronPDF and Spire.PDF for .NET, we will compare their implementation of several key PDF functionalities through code examples, giving you an idea of how these features could help with your PDF projects.

Convert HTML to PDF

IronPDF Example:

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>");
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>");
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>")
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")
$vbLabelText   $csharpLabel

The ChromePdfRenderer class in IronPDF leverages a full Chrome browser engine to render HTML content. This means CSS3 animations, JavaScript execution, and modern web fonts all render exactly as they would in Chrome. The RenderHtmlAsPdf() method accepts HTML strings and optional base paths for loading external assets, making it straightforward to convert both simple and complex HTML documents. The renderer supports advanced rendering options including custom paper sizes, margins, and JavaScript delay settings.

Spire.PDF Example:

using Spire.Pdf;
using Spire.Pdf.HtmlConverter;
using System.IO;
using System.Threading;
using System.Drawing;

namespace ConvertHtmlStringToPdfWithoutPlugin
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            // Create a PdfPageSettings object
            PdfPageSettings setting = new PdfPageSettings();

            // Set page size and margins through the object
            setting.Size = new SizeF(1000, 1000);
            setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

            // Create a PdfHtmlLayoutFormat object
            PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();

            // Set IsWaiting property to true
            htmlLayoutFormat.IsWaiting = true;

            // Read HTML string from a .html file
            string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");

            // Load HTML from HTML string using LoadFromHTML method
            Thread thread = new Thread(() =>
            { doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat); });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            // Save to a PDF file
            doc.SaveToFile("HtmlStringToPdf.pdf");
        }
    }
}
using Spire.Pdf;
using Spire.Pdf.HtmlConverter;
using System.IO;
using System.Threading;
using System.Drawing;

namespace ConvertHtmlStringToPdfWithoutPlugin
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            // Create a PdfPageSettings object
            PdfPageSettings setting = new PdfPageSettings();

            // Set page size and margins through the object
            setting.Size = new SizeF(1000, 1000);
            setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

            // Create a PdfHtmlLayoutFormat object
            PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();

            // Set IsWaiting property to true
            htmlLayoutFormat.IsWaiting = true;

            // Read HTML string from a .html file
            string htmlString = File.ReadAllText(@"C:\Users\Administrator\Desktop\Document\Html\Sample.html");

            // Load HTML from HTML string using LoadFromHTML method
            Thread thread = new Thread(() =>
            { doc.LoadFromHTML(htmlString, true, setting, htmlLayoutFormat); });
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            // Save to a PDF file
            doc.SaveToFile("HtmlStringToPdf.pdf");
        }
    }
}
Imports Spire.Pdf
Imports Spire.Pdf.HtmlConverter
Imports System.IO
Imports System.Threading
Imports System.Drawing

Namespace ConvertHtmlStringToPdfWithoutPlugin
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			' Create a PdfDocument object
			Dim doc As New PdfDocument()

			' Create a PdfPageSettings object
			Dim setting As New PdfPageSettings()

			' Set page size and margins through the object
			setting.Size = New SizeF(1000, 1000)
			setting.Margins = New Spire.Pdf.Graphics.PdfMargins(20)

			' Create a PdfHtmlLayoutFormat object
			Dim htmlLayoutFormat As New PdfHtmlLayoutFormat()

			' Set IsWaiting property to true
			htmlLayoutFormat.IsWaiting = True

			' Read HTML string from a .html file
			Dim htmlString As String = File.ReadAllText("C:\Users\Administrator\Desktop\Document\Html\Sample.html")

			' Load HTML from HTML string using LoadFromHTML method
			Dim thread As New Thread(Sub()
				doc.LoadFromHTML(htmlString, True, setting, htmlLayoutFormat)
			End Sub)
			thread.SetApartmentState(ApartmentState.STA)
			thread.Start()
			thread.Join()

			' Save to a PDF file
			doc.SaveToFile("HtmlStringToPdf.pdf")
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

Spire.PDF's HTML to PDF conversion requires creating multiple objects including PdfDocument, PdfPageSettings, and PdfHtmlLayoutFormat. The conversion must be executed in a Single Thread Apartment (STA) thread, adding complexity to the implementation. Users have reported that "Spire generates a PDF file that is just an image. Some of the css is not even correct, such as ignoring bold fonts", indicating limitations in CSS rendering fidelity.

IronPDF uses Chrome's rendering engine for high-fidelity HTML to PDF conversion, ensuring an accurate representation of web content thanks to its support for modern web standards. Spire.PDF also provides robust HTML to PDF conversion but may not match the rendering precision of IronPDF, and takes a longer, more manual approach.

How Can You Encrypt PDF Documents?

IronPDF Example:

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
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = 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
pdf.SecuritySettings.RemovePasswordsAndEncryption();
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key");
pdf.SecuritySettings.AllowUserAnnotations = false;
pdf.SecuritySettings.AllowUserCopyPasteContent = false;
pdf.SecuritySettings.AllowUserFormData = false;
pdf.SecuritySettings.AllowUserPrinting = 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
pdf.SecuritySettings.RemovePasswordsAndEncryption()
pdf.SecuritySettings.MakePdfDocumentReadOnly("secret-key")
pdf.SecuritySettings.AllowUserAnnotations = False
pdf.SecuritySettings.AllowUserCopyPasteContent = False
pdf.SecuritySettings.AllowUserFormData = False
pdf.SecuritySettings.AllowUserPrinting = PdfPrintSecurity.FullPrintRights

' Change or set the document encryption password
pdf.Password = "my-password"
pdf.SaveAs("secured.pdf")
$vbLabelText   $csharpLabel

IronPDF's SecuritySettings class provides a comprehensive API for managing PDF security. You can control individual permissions with boolean properties, set different levels of printing rights, and manage passwords separately from other security settings. The API design follows .NET conventions with strongly-typed enumerations like PdfPrintSecurity. Learn more about PDF permissions and passwords in the documentation.

Spire.PDF Example:

using Spire.Pdf;
using Spire.Pdf.Security;

// Create a PdfDocument object
PdfDocument pdf = new PdfDocument();

// Load a sample PDF file
pdf.LoadFromFile(@"E:\Files\sample.pdf");

// Encrypt the PDF file with a password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print | PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit);

// Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF);
using Spire.Pdf;
using Spire.Pdf.Security;

// Create a PdfDocument object
PdfDocument pdf = new PdfDocument();

// Load a sample PDF file
pdf.LoadFromFile(@"E:\Files\sample.pdf");

// Encrypt the PDF file with a password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print | PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit);

// Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF);
Imports Spire.Pdf
Imports Spire.Pdf.Security

' Create a PdfDocument object
Private pdf As New PdfDocument()

' Load a sample PDF file
pdf.LoadFromFile("E:\Files\sample.pdf")

' Encrypt the PDF file with a password
pdf.Security.Encrypt("open", "permission", PdfPermissionsFlags.Print Or PdfPermissionsFlags.CopyContent, PdfEncryptionKeySize.Key128Bit)

' Save the result file
pdf.SaveToFile("Encrypt.pdf", FileFormat.PDF)
$vbLabelText   $csharpLabel

Spire.PDF's encryption approach uses the Security.Encrypt() method with bitwise flags for permissions. While more compact, this approach requires understanding of bitwise operations and offers less granular control compared to IronPDF's individual permission properties.

Both libraries provide easy-to-use methods for encrypting PDFs and setting the encrypted PDF documents' readability. IronPDF offers a straightforward approach while still giving you full control over the security settings of your PDF. Spire.PDF takes a slightly shorter process but still includes additional options for setting permissions.

What Are the Options for Redacting PDF Content?

IronPDF Example:

using IronPdf;

// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");

// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");

// Save the redacted document
pdf.SaveAs("redacted.pdf");
using IronPdf;

// Load the PDF document
PdfDocument pdf = PdfDocument.FromFile("novel.pdf");

// Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are");

// Save the redacted document
pdf.SaveAs("redacted.pdf");
Imports IronPdf

' Load the PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("novel.pdf")

' Redact 'are' phrase from all pages
pdf.RedactTextOnAllPages("are")

' Save the redacted document
pdf.SaveAs("redacted.pdf")
$vbLabelText   $csharpLabel

IronPDF provides a dedicated redaction API that performs true content removal, not just visual masking. The RedactTextOnAllPages() method searches for and permanently removes specified text, ensuring compliance with data protection regulations. Additional methods allow redaction on specific pages or regions.

Spire.PDF Example for Redaction via Rectangle Overlay:

While Spire.PDF does not have a dedicated redaction tool, content can still be redacted using a manual process, as demonstrated below:

using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

// Specify the input PDF file path
string inputPdfFilePath = "path/to/your/input.pdf";

// Specify the output redacted PDF file path
string outputPdfFilePath = "path/to/your/redacted_output.pdf";

// Create a new PdfDocument object
PdfDocument pdfDocument = new PdfDocument();

// Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath);

// Redact content on each page
foreach (PdfPageBase page in pdfDocument.Pages)
{
    // Define the area to redact (e.g., coordinates and size of the rectangle)
    RectangleF redactArea = new RectangleF(100, 100, 200, 50); // Example coordinates and size

    // Apply redaction
    page.Canvas.DrawRectangle(new PdfSolidBrush(Color.Black), redactArea);
}

// Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath);
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

// Specify the input PDF file path
string inputPdfFilePath = "path/to/your/input.pdf";

// Specify the output redacted PDF file path
string outputPdfFilePath = "path/to/your/redacted_output.pdf";

// Create a new PdfDocument object
PdfDocument pdfDocument = new PdfDocument();

// Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath);

// Redact content on each page
foreach (PdfPageBase page in pdfDocument.Pages)
{
    // Define the area to redact (e.g., coordinates and size of the rectangle)
    RectangleF redactArea = new RectangleF(100, 100, 200, 50); // Example coordinates and size

    // Apply redaction
    page.Canvas.DrawRectangle(new PdfSolidBrush(Color.Black), redactArea);
}

// Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath);
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing

' Specify the input PDF file path
Private inputPdfFilePath As String = "path/to/your/input.pdf"

' Specify the output redacted PDF file path
Private outputPdfFilePath As String = "path/to/your/redacted_output.pdf"

' Create a new PdfDocument object
Private pdfDocument As New PdfDocument()

' Load the existing PDF document
pdfDocument.LoadFromFile(inputPdfFilePath)

' Redact content on each page
For Each page As PdfPageBase In pdfDocument.Pages
	' Define the area to redact (e.g., coordinates and size of the rectangle)
	Dim redactArea As New RectangleF(100, 100, 200, 50) ' Example coordinates and size

	' Apply redaction
	page.Canvas.DrawRectangle(New PdfSolidBrush(Color.Black), redactArea)
Next page

' Save the redacted PDF document
pdfDocument.SaveToFile(outputPdfFilePath)
$vbLabelText   $csharpLabel

This manual approach requires calculating exact coordinates for each redaction area and only provides visual masking rather than true content removal. The underlying text may still be extractable through PDF editing tools.

IronPDF simplifies redaction with its robust, yet straightforward, redaction tool. Spire.PDF requires more manual handling for redaction due to the absence of a built-in redaction tool, resulting in potentially less efficient workflows.

How Do You Sign PDF Documents?

IronPDF Example:

using IronPdf;
using IronPdf.Signing;
using System.Security.Cryptography.X509Certificates;

// Instantiate the 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 with certificate
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 the 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 with certificate
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 the 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 with certificate
Private sig = New PdfSignature(cert)

' Sign PDF document
pdf.Sign(sig)
pdf.SaveAs("signed.pdf")
$vbLabelText   $csharpLabel

IronPDF's digital signature implementation follows .NET certificate handling patterns. The PdfSignature class accepts standard X509Certificate2 objects and handles the complexities of PDF signing internally. You can also add visual signature appearances and configure signature fields.

Spire.PDF Example:

using Spire.Pdf;
using Spire.Pdf.Security;
using System.Drawing;

// Create a PdfDocument object
PdfDocument doc = new PdfDocument();

// Load a sample PDF file
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pdf");

// Load the certificate
PdfCertificate cert = new PdfCertificate("C:\\Users\\Administrator\\Desktop\\MyCertificate.pfx", "e-iceblue");

// Create a PdfSignature object and specify its position and size
PdfSignature signature = new PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "MySignature");
RectangleF rectangleF = new RectangleF(doc.Pages[0].ActualSize.Width - 260 - 54 , 200, 260, 110);
signature.Bounds = rectangleF;
signature.Certificated = true;

// Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;

// Set various details about the signature
signature.NameLabel = "Signer:";
signature.Name = "Gary";
signature.ContactInfoLabel = "Phone:";
signature.ContactInfo = "0123456";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "USA";
signature.ReasonLabel = "Reason:";
signature.Reason = "I am the author";
signature.DistinguishedNameLabel = "DN:";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;

// Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\\Users\\Administrator\\Desktop\\handwrittingSignature.png");

// Set the signature font
signature.SignDetailsFont = new PdfTrueTypeFont(new Font("Arial Unicode MS", 12f, FontStyle.Regular));

// Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges | PdfCertificationFlags.AllowFormFill;

// Save to file
doc.SaveToFile("VisiableSignature.pdf");
using Spire.Pdf;
using Spire.Pdf.Security;
using System.Drawing;

// Create a PdfDocument object
PdfDocument doc = new PdfDocument();

// Load a sample PDF file
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pdf");

// Load the certificate
PdfCertificate cert = new PdfCertificate("C:\\Users\\Administrator\\Desktop\\MyCertificate.pfx", "e-iceblue");

// Create a PdfSignature object and specify its position and size
PdfSignature signature = new PdfSignature(doc, doc.Pages[doc.Pages.Count - 1], cert, "MySignature");
RectangleF rectangleF = new RectangleF(doc.Pages[0].ActualSize.Width - 260 - 54 , 200, 260, 110);
signature.Bounds = rectangleF;
signature.Certificated = true;

// Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;

// Set various details about the signature
signature.NameLabel = "Signer:";
signature.Name = "Gary";
signature.ContactInfoLabel = "Phone:";
signature.ContactInfo = "0123456";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.LocationInfoLabel = "Location:";
signature.LocationInfo = "USA";
signature.ReasonLabel = "Reason:";
signature.Reason = "I am the author";
signature.DistinguishedNameLabel = "DN:";
signature.DistinguishedName = signature.Certificate.IssuerName.Name;

// Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\\Users\\Administrator\\Desktop\\handwrittingSignature.png");

// Set the signature font
signature.SignDetailsFont = new PdfTrueTypeFont(new Font("Arial Unicode MS", 12f, FontStyle.Regular));

// Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges | PdfCertificationFlags.AllowFormFill;

// Save to file
doc.SaveToFile("VisiableSignature.pdf");
Imports Spire.Pdf
Imports Spire.Pdf.Security
Imports System.Drawing

' Create a PdfDocument object
Private doc As New PdfDocument()

' Load a sample PDF file
doc.LoadFromFile("C:\Users\Administrator\Desktop\sample.pdf")

' Load the certificate
Dim cert As New PdfCertificate("C:\Users\Administrator\Desktop\MyCertificate.pfx", "e-iceblue")

' Create a PdfSignature object and specify its position and size
Dim signature As New PdfSignature(doc, doc.Pages(doc.Pages.Count - 1), cert, "MySignature")
Dim rectangleF As New RectangleF(doc.Pages(0).ActualSize.Width - 260 - 54, 200, 260, 110)
signature.Bounds = rectangleF
signature.Certificated = True

' Set the graphics mode to ImageAndSignDetail
signature.GraphicsMode = GraphicMode.SignImageAndSignDetail

' Set various details about the signature
signature.NameLabel = "Signer:"
signature.Name = "Gary"
signature.ContactInfoLabel = "Phone:"
signature.ContactInfo = "0123456"
signature.DateLabel = "Date:"
signature.Date = DateTime.Now
signature.LocationInfoLabel = "Location:"
signature.LocationInfo = "USA"
signature.ReasonLabel = "Reason:"
signature.Reason = "I am the author"
signature.DistinguishedNameLabel = "DN:"
signature.DistinguishedName = signature.Certificate.IssuerName.Name

' Set the signature image source
signature.SignImageSource = PdfImage.FromFile("C:\Users\Administrator\Desktop\handwrittingSignature.png")

' Set the signature font
signature.SignDetailsFont = New PdfTrueTypeFont(New Font("Arial Unicode MS", 12F, FontStyle.Regular))

' Set the document permission to forbid changes but allow form fill
signature.DocumentPermissions = PdfCertificationFlags.ForbidChanges Or PdfCertificationFlags.AllowFormFill

' Save to file
doc.SaveToFile("VisiableSignature.pdf")
$vbLabelText   $csharpLabel

Spire.PDF provides extensive control over signature appearance but requires significantly more code. You must manually set each label, position the signature precisely, and configure visual elements separately.

Digitally signing PDFs can be helpful in various settings, from being used to authenticate PDF documents to simply signing off on a new project. IronPDF offers a straightforward approach to adding digital signatures, allowing easy automation of the signing process. Spire.PDF also supports digital signatures for PDFs; however, the process can be more manual and require more effort to implement.

What Methods Are Available for Watermarking PDFs?

IronPDF Example:

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")
$vbLabelText   $csharpLabel

IronPDF's watermarking feature accepts HTML content, allowing you to use CSS for styling. The ApplyWatermark() method provides parameters for rotation angle and alignment, making it easy to position watermarks precisely. Learn more about custom watermarks and advanced styling options.

Spire.PDF Example:

using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

// Create a PdfDocument object
PdfDocument pdf = new PdfDocument();

// Load a sample PDF document
pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf");

// Create a PdfTrueTypeFont object
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 50f), true);

// Set the watermark text
string text = "CONFIDENTIAL";

// Measure the text size
SizeF textSize = font.MeasureString(text);

// Calculate the values of two offset variables,
// which will be used to calculate the translation amount of the coordinate system
float offset1 = (float)(textSize.Width * System.Math.Sqrt(2) / 4);
float offset2 = (float)(textSize.Height * System.Math.Sqrt(2) / 4);

// Traverse all the pages in the document
foreach (PdfPageBase page in pdf.Pages)
{
    // Set the page transparency
    page.Canvas.SetTransparency(0.8f);

    // Translate the coordinate system by specified coordinates
    page.Canvas.TranslateTransform(page.Canvas.Size.Width / 2 - offset1 - offset2, page.Canvas.Size.Height / 2 + offset1 - offset2);

    // Rotate the coordinate system 45 degrees counterclockwise
    page.Canvas.RotateTransform(-45);

    // Draw watermark text on the page
    page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0);
}

// Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf");
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

// Create a PdfDocument object
PdfDocument pdf = new PdfDocument();

// Load a sample PDF document
pdf.LoadFromFile(@"C:\Users\Administrator\Desktop\sample.pdf");

// Create a PdfTrueTypeFont object
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 50f), true);

// Set the watermark text
string text = "CONFIDENTIAL";

// Measure the text size
SizeF textSize = font.MeasureString(text);

// Calculate the values of two offset variables,
// which will be used to calculate the translation amount of the coordinate system
float offset1 = (float)(textSize.Width * System.Math.Sqrt(2) / 4);
float offset2 = (float)(textSize.Height * System.Math.Sqrt(2) / 4);

// Traverse all the pages in the document
foreach (PdfPageBase page in pdf.Pages)
{
    // Set the page transparency
    page.Canvas.SetTransparency(0.8f);

    // Translate the coordinate system by specified coordinates
    page.Canvas.TranslateTransform(page.Canvas.Size.Width / 2 - offset1 - offset2, page.Canvas.Size.Height / 2 + offset1 - offset2);

    // Rotate the coordinate system 45 degrees counterclockwise
    page.Canvas.RotateTransform(-45);

    // Draw watermark text on the page
    page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0);
}

// Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf");
Imports System
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing

' Create a PdfDocument object
Private pdf As New PdfDocument()

' Load a sample PDF document
pdf.LoadFromFile("C:\Users\Administrator\Desktop\sample.pdf")

' Create a PdfTrueTypeFont object
Dim font As New PdfTrueTypeFont(New Font("Arial", 50F), True)

' Set the watermark text
Dim text As String = "CONFIDENTIAL"

' Measure the text size
Dim textSize As SizeF = font.MeasureString(text)

' Calculate the values of two offset variables,
' which will be used to calculate the translation amount of the coordinate system
Dim offset1 As Single = CSng(textSize.Width * Math.Sqrt(2) / 4)
Dim offset2 As Single = CSng(textSize.Height * Math.Sqrt(2) / 4)

' Traverse all the pages in the document
For Each page As PdfPageBase In pdf.Pages
	' Set the page transparency
	page.Canvas.SetTransparency(0.8F)

	' Translate the coordinate system by specified coordinates
	page.Canvas.TranslateTransform(page.Canvas.Size.Width \ 2 - offset1 - offset2, page.Canvas.Size.Height \ 2 + offset1 - offset2)

	' Rotate the coordinate system 45 degrees counterclockwise
	page.Canvas.RotateTransform(-45)

	' Draw watermark text on the page
	page.Canvas.DrawString(text, font, PdfBrushes.DarkGray, 0, 0)
Next page

' Save the changes to another file
pdf.SaveToFile("TextWatermark.pdf")
$vbLabelText   $csharpLabel

Spire.PDF's watermarking requires manual calculation of positioning and rotation using coordinate system transformations. While this provides fine control, it requires understanding of graphics programming concepts.

IronPDF provides an easy method for adding text watermarks while giving you full control over the position and design of the watermark. IronPDF's use of HTML and CSS makes the process easier if you have experience with these languages. Spire.PDF's approach is longer with a more manual process but still provides a strong watermarking tool with full control over the design and position.

How Can You Stamp Images and Text on PDFs?

IronPDF Example:

using IronPdf;
using IronPdf.Editing;

// Instantiate Renderer
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");

// 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;

// Instantiate Renderer
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");

// 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

' Instantiate Renderer
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")

' Create image stamper
Dim 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")
$vbLabelText   $csharpLabel

IronPDF's stamping API uses dedicated classes for different stamp types. The TextStamper supports Google Fonts directly through the UseGoogleFont property, while ImageStamper can load images from URLs or local files. Both stampers share common alignment properties for consistent positioning. Explore more stamping options including HTML stampers and barcode integration.

Spire.PDF (Text Stamping Example):

using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

// Assumes a PdfDocument is already loaded as `doc` object
PdfPageBase page = doc.Pages[0];
PdfGraphicsState state = page.Canvas.Save();

// Define font and brushes for different effects
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);

// Apply transformations and draw strings with shadow and effect
page.Canvas.TranslateTransform(20, 200);
page.Canvas.ScaleTransform(1f, 0.6f);
page.Canvas.SkewTransform(-10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0);
page.Canvas.SkewTransform(10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0);
page.Canvas.ScaleTransform(1f, -1f);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18);

// Restore graphics to previous state
page.Canvas.Restore(state);
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

// Assumes a PdfDocument is already loaded as `doc` object
PdfPageBase page = doc.Pages[0];
PdfGraphicsState state = page.Canvas.Save();

// Define font and brushes for different effects
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 18f);
PdfSolidBrush brush1 = new PdfSolidBrush(Color.DeepSkyBlue);
PdfSolidBrush brush2 = new PdfSolidBrush(Color.CadetBlue);

// Apply transformations and draw strings with shadow and effect
page.Canvas.TranslateTransform(20, 200);
page.Canvas.ScaleTransform(1f, 0.6f);
page.Canvas.SkewTransform(-10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0);
page.Canvas.SkewTransform(10, 0);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0);
page.Canvas.ScaleTransform(1f, -1f);
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18);

// Restore graphics to previous state
page.Canvas.Restore(state);
Imports Spire.Pdf
Imports Spire.Pdf.Graphics
Imports System.Drawing

' Assumes a PdfDocument is already loaded as `doc` object
Private page As PdfPageBase = doc.Pages(0)
Private state As PdfGraphicsState = page.Canvas.Save()

' Define font and brushes for different effects
Private font As New PdfFont(PdfFontFamily.Helvetica, 18F)
Private brush1 As New PdfSolidBrush(Color.DeepSkyBlue)
Private brush2 As New PdfSolidBrush(Color.CadetBlue)

' Apply transformations and draw strings with shadow and effect
page.Canvas.TranslateTransform(20, 200)
page.Canvas.ScaleTransform(1F, 0.6F)
page.Canvas.SkewTransform(-10, 0)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush1, 0, 0)
page.Canvas.SkewTransform(10, 0)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, 0)
page.Canvas.ScaleTransform(1F, -1F)
page.Canvas.DrawString("Go! Turn Around! Go! Go! Go!", font, brush2, 0, -2 * 18)

' Restore graphics to previous state
page.Canvas.Restore(state)
$vbLabelText   $csharpLabel

Spire.PDF requires direct canvas manipulation with manual transformations for each effect. Creating complex stamps involves understanding graphics state management and coordinate transformations.

IronPDF's text and image stamping tool is a powerful, easy-to-use stamping tool that follows an approach similar to HTML and CSS when you apply the stamped content. While Spire.PDF also offers a basic text stamping tool, it requires more effort to apply the stamped text to your PDF files.

Which Library Handles DOCX to PDF Conversion Better?

IronPDF Example:

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")
$vbLabelText   $csharpLabel

IronPDF includes a dedicated DocxToPdfRenderer class that handles DOCX conversion natively. The API is consistent with other rendering classes in IronPDF, requiring just two lines of code for basic conversion. Advanced options for page setup and formatting are available through the renderer's properties. Learn more about DOCX to PDF conversion features.

Spire.PDF Using Spire.Doc for DOCX to PDF Conversion:

Spire.PDF itself cannot convert DOCX to PDF; however, the Spire.Doc library can be used to handle this conversion, and then you can use Spire.PDF to work on the resultant PDF.

using Spire.Doc;

// Create a Document object
Document doc = new Document();

// Load a Word document
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.docx");

// Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF);

// Dispose of resources
doc.Dispose();
using Spire.Doc;

// Create a Document object
Document doc = new Document();

// Load a Word document
doc.LoadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.docx");

// Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF);

// Dispose of resources
doc.Dispose();
Imports Spire.Doc

' Create a Document object
Private doc As New Document()

' Load a Word document
doc.LoadFromFile("C:\Users\Administrator\Desktop\Sample.docx")

' Save the document to PDF
doc.SaveToFile("ToPDF.pdf", FileFormat.PDF)

' Dispose of resources
doc.Dispose()
$vbLabelText   $csharpLabel

This approach requires purchasing and managing an additional library (Spire.Doc), increasing both cost and complexity.

IronPDF offers built-in support for direct DOCX to PDF conversion, meaning you save time without needing additional libraries to handle this task. Spire.PDF, on the other hand, cannot directly handle DOCX to PDF conversion, requiring the Spire.Doc library to convert DOCX files to PDF.

What Do the Performance Metrics Reveal?

Based on testing and user feedback, here's how the libraries compare in real-world usage:

Rendering Performance

For basic layouts, Spire.PDF is optimized for simple content like static tables or basic styled text, making it fast and efficient for these use cases. However, when dealing with complex HTML containing modern CSS3 features, JavaScript, or responsive layouts, IronPDF's Chrome-based engine provides more accurate results at the cost of slightly higher rendering times.

Memory Usage

Spire.PDF generally uses less memory (80-120MB) compared to IronPDF (150-200MB) due to its simpler rendering engine. However, this comes at the cost of rendering fidelity and feature support. For applications where memory is critical and HTML complexity is minimal, Spire.PDF may be advantageous.

Threading and Async Support

IronPDF provides native async/await support with methods like RenderHtmlAsPdfAsync(), making it suitable for modern .NET applications. Spire.PDF requires manual thread management with STA threads, adding complexity to multi-threaded applications.

How Do Pricing and Licensing Models Compare?

IronPDF Pricing and Licensing

IronPDF offers various levels and additional features for purchasing a license. Developers can also buy Iron Suite which gives access to all of Iron Software's products at the price of two. If you're not ready to buy a license, IronPDF provides a free trial that lasts 30 days.

  • 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.
  • Iron Suite: For $1,498, you get access to all Iron Software products including IronPDF, IronOCR, IronWord, IronXL, IronBarcode, IronQR, IronZIP, IronPrint, and IronWebScraper.

IronPDF Pricing Chart IronPDF offers flexible licensing options with perpetual licenses and comprehensive support included

Spire.PDF Pricing and Licensing

Spire.PDF offers a range of licenses depending on your needs.

  • Free version: Spire.PDF offers a free version limited to 10 PDF pages; beyond this, you would need to purchase a paid license.
  • Developer Subscription: Priced at either $999 or $1,199 per year depending on the type of support you need, this option is for developers who need to build PDF-related features but don't require OEM distribution rights.
  • Developer OEM Subscription: Costs around $2,549 - $4,248 per year depending on the amount of support you need, and includes free upgrades, premium support, and the ability to distribute the application to end-users.
  • Site Small Business: Priced at either $4,599 or $7,598 depending on the support you want, this licensing tier supports up to 10 developers across up to 10 locations, updates for 1 year, and free online technical resources.
  • Site OEM Subscription: Costs $13,088 - $16,687 per year depending on the type of support you need and is aimed at larger enterprises that need to deploy applications to multiple locations.

Which Library Provides Better Documentation and Support?

IronPDF

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.
  • PDF API reference: Offers API references so you can get the most out of what our tools have to offer.

For more information, check out IronPDF's extensive documentation, and visit the Iron Software YouTube Channel.

Spire.PDF for .NET Documentation and Support

  • Forums: Spire.PDF has a forum where users can interact with one another, sharing tips, uses, and issues encountered with Spire.PDF.
  • Code Samples: Spire.PDF offers code examples on their website to show how to use the product in various use cases.
  • Newsletters: Spire.PDF offers a developer's newsletter for update announcements and other important information.
  • Support: Support is primarily through forums, with paid email/phone support available at additional cost depending on the licensing version.

What Are Common Developer Experiences and Feedback?

Based on community feedback and real-world usage:

IronPDF Feedback

Developers consistently praise IronPDF for providing "a more comprehensive and precise representation of the original HTML page". The library's ability to handle complex CSS3 layouts, JavaScript-heavy pages, and modern web frameworks makes it a preferred choice for applications requiring high-fidelity PDF generation.

Common positive points include:

  • Intuitive API design that reduces development time
  • Excellent rendering quality matching browser output
  • Comprehensive documentation with practical examples
  • Responsive technical support

Spire.PDF Feedback

Community feedback indicates that "Spire generates a PDF file that is just an image. Some of the css is not even correct, such as ignoring bold fonts". Additionally, JavaScript support remains a planned feature that "would be so difficult that it is not completed in a short time" according to official support responses.

Common concerns include:

  • Limited CSS3 and modern web standard support
  • Lack of JavaScript execution capability
  • Complex threading requirements for HTML conversion
  • Additional library requirements for certain features

When Should You Choose Each Library?

Choose IronPDF When:

  • Your HTML contains modern CSS3, JavaScript, or responsive designs
  • You need pixel-perfect rendering matching browser output
  • Cross-platform deployment is required (Linux, macOS, Docker)
  • You want comprehensive support included with your license
  • You need built-in features like DOCX conversion without additional libraries
  • Your team values rapid development with minimal code

Choose Spire.PDF When:

  • Your PDFs contain only basic HTML with simple styling
  • Memory usage is a critical constraint
  • You primarily work in Windows environments
  • Your HTML doesn't require JavaScript execution
  • You already use other Spire products in your stack

Conclusion

In conclusion, IronPDF and Spire.PDF for .NET are both capable tools for handling PDF documents in .NET applications. IronPDF excels in ease of use, cross-platform compatibility, and support for modern web standards, making it a preferred choice if you are looking to step up your game when working with PDF documents. Spire.PDF offers a comprehensive set of features but may require more effort for complex tasks and lacks the rendering precision that modern web applications demand.

For developers working with contemporary web technologies, requiring accurate HTML to PDF conversion, or needing reliable cross-platform support, IronPDF presents a more complete solution. Its Chrome-based rendering engine, intuitive API, and comprehensive support make it particularly suitable for enterprise applications and complex document generation scenarios.

You can try the 30-day free trial to check out their available features.

Please noteSpire.PDF is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by Spire.PDF. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.

Frequently Asked Questions

How can I convert HTML to PDF in C#?

You can use IronPDF's RenderHtmlAsPdf method to convert HTML strings into PDFs. You can also convert HTML files into PDFs using RenderHtmlFileAsPdf.

Does IronPDF support JavaScript execution during HTML to PDF conversion?

Yes, IronPDF supports full JavaScript execution, making it ideal for converting dynamic content or JavaScript-dependent layouts into PDF.

What platforms are supported by IronPDF for PDF conversion?

IronPDF offers native support across multiple platforms, including Windows, Linux, macOS, Docker, as well as cloud services like Azure and AWS.

How does the memory usage of IronPDF compare to Spire.PDF?

IronPDF uses slightly more memory, typically between 150-200MB, compared to Spire.PDF's 80-120MB, but it provides better rendering quality and supports modern async/await patterns.

Can IronPDF convert DOCX files to PDF directly?

Yes, IronPDF includes built-in DOCX to PDF conversion capabilities through its DocxToPdfRenderer class without requiring additional libraries.

What are the licensing options for IronPDF?

IronPDF offers perpetual licenses starting at $749 for single developers, including all features and support. It also provides an Iron Suite bundle with 9 products for $1,498.

What kind of support does IronPDF offer?

IronPDF provides 24/5 engineering support via email, chat, phone, and screen sharing with all licenses, ensuring comprehensive assistance.

How can I ensure PDF security and encryption with IronPDF?

IronPDF supports AES-256 encryption and password protection through its SecuritySettings class, allowing granular control over PDF permissions.

Is IronPDF suitable for rendering complex web pages with modern CSS?

Yes, IronPDF uses a full Chrome rendering engine that supports CSS3, flexbox, grid layouts, web fonts, and JavaScript, making it well-suited for complex web pages.

What are the limitations of the free version of IronPDF?

IronPDF offers a fully-functional 30-day free trial with no page limits, providing ample opportunity to test all its features before committing to a purchase.

How does IronPDF ensure high-quality HTML rendering?

IronPDF delivers pixel-perfect rendering that matches Chrome browser output, ensuring high fidelity and accurate representation of the original HTML content.

Jacob Mellor, Chief Technology Officer @ Team Iron
Chief Technology Officer

Jacob Mellor is Chief Technology Officer at Iron Software and a visionary engineer pioneering C# PDF technology. As the original developer behind Iron Software's core codebase, he has shaped the company's product architecture since its inception, transforming it alongside CEO Cameron Rimington into a 50+ person company serving NASA, Tesla, ...Read More