SpirePDF C# HTML to PDF Tutorial & Library Comparison

Working with PDFs in .NET, we need C# developed PDF manipulation and generation libraries that can accomplish all our tasks. SpirePDF and IronPDF both provide the ability to create, edit and print PDF files in .NET and .NET Core. They can also read PDF text, data, table, and image examples very competently.

Let's compare the two.

PDF from URL
private void ExistingWebURL()
{
	var Renderer = new IronPdf.HtmlToPdf();
	var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");

	// Create a PDF from an existing HTML
	Renderer.PrintOptions.MarginTop = 50;  //millimetres
	Renderer.PrintOptions.MarginBottom = 50;
	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;
	Renderer.PrintOptions.Header = new SimpleHeaderFooter()
	{
		CenterText = "{pdf-title}",
		DrawDividerLine = true,
		FontSize = 16
	};
	Renderer.PrintOptions.Footer = new SimpleHeaderFooter()
	{
		LeftText = "{date} {time}",
		RightText = "Page {page} of {total-pages}",
		DrawDividerLine = true,
		FontSize = 14
	};


	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;

	Renderer.PrintOptions.EnableJavaScript = true;
	Renderer.PrintOptions.RenderDelay = 500; //milliseconds

	PDF.SaveAs("wikipedia.pdf");
}
Private Sub ExistingWebURL()
	Dim Renderer = New IronPdf.HtmlToPdf()
	Dim PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format")

	' Create a PDF from an existing HTML
	Renderer.PrintOptions.MarginTop = 50 'millimetres
	Renderer.PrintOptions.MarginBottom = 50
	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print
	Renderer.PrintOptions.Header = New SimpleHeaderFooter() With {
		.CenterText = "{pdf-title}",
		.DrawDividerLine = True,
		.FontSize = 16
	}
	Renderer.PrintOptions.Footer = New SimpleHeaderFooter() With {
		.LeftText = "{date} {time}",
		.RightText = "Page {page} of {total-pages}",
		.DrawDividerLine = True,
		.FontSize = 14
	}


	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print

	Renderer.PrintOptions.EnableJavaScript = True
	Renderer.PrintOptions.RenderDelay = 500 'milliseconds

	PDF.SaveAs("wikipedia.pdf")
End Sub
Jump to Article
PDF from HTML String
private void HTMLString()
{
	var Renderer = new IronPdf.HtmlToPdf();
	var PDF = Renderer.RenderHtmlAsPdf("<h1>Hi there IronPdf</h1>");

	Renderer.PrintOptions.Footer = new HtmlHeaderFooter() { HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>" };

	var OutputPath = "HtmlToPDF.pdf";
	PDF.SaveAs(OutputPath);
	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen;
}
Private Sub HTMLString()
	Dim Renderer = New IronPdf.HtmlToPdf()
	Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Hi there IronPdf</h1>")

	Renderer.PrintOptions.Footer = New HtmlHeaderFooter() With {.HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"}

	Dim OutputPath = "HtmlToPDF.pdf"
	PDF.SaveAs(OutputPath)
	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen
End Sub
Jump to Article
ASPX to PDF
protected void Page_Load(object sender, EventArgs e)
{

	IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

	IronPdf.AspxToPdf.RenderThisPageAsPdf()
End Sub
Jump to Article
XML to PDF
private void XMLtoPDF(string XSLT, string XML)
{
	XslCompiledTransform transform = new XslCompiledTransform();
	using(XmlReader reader = XmlReader.Create(new StringReader(XSLT)))
	{
		transform.Load(reader);
	}

	StringWriter results = new StringWriter();
	using(XmlReader reader = XmlReader.Create(new StringReader(XML)))
	{
		transform.Transform(reader, null, results);
	}

	IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
	Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("XMLtoPDF.pdf");
}
Private Sub XMLtoPDF(ByVal XSLT As String, ByVal XML As String)
	Dim transform As New XslCompiledTransform()
	Using reader As XmlReader = XmlReader.Create(New StringReader(XSLT))
		transform.Load(reader)
	End Using

	Dim results As New StringWriter()
	Using reader As XmlReader = XmlReader.Create(New StringReader(XML))
		transform.Transform(reader, Nothing, results)
	End Using

	Dim Renderer As New IronPdf.HtmlToPdf()
	Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("XMLtoPDF.pdf")
End Sub
Jump to Article
Try IronPDF free for development


Overview

There are many times that the tools provided to us by Microsoft as part of Visual Studio are lacking functionality or usability. This is where third-party libraries come in. Developers make use of third-party libraries for their ease of use, or, mostly, for their features.

This article will compare two of the most popular PDF libraries for .NET and .NET Core developers. These two libraries are:

  • IronPDF
  • SpirePDF

We will show what each PDF library can do and compare how they do it through code examples and step-by-step tutorials. Although this article cannot cover all features of both PDF libraries, it will explain the most common and most popular uses of each.

Learn about Spire.PDF

Spire.PDF for .NET is an API that can be applied to creating, editing, writing, reading and handling PDF files without the need for any external dependencies in C#, VB.NET, ASP.NET, .NET Core, Xamarin applications. With Spire.PDF you can create PDF files from scratch or process existing PDF documents solely through C#/VB.NET without having to install Adobe Acrobat.

Learn about IronPDF

IronPDF enables .NET and .NET Core developers to generate, merge, split, edit, and extract pdf content easily in C#, F#, and VB.Net for .NET Core and .NET Framework, as well as create PDFs from HTML, ASPX, CSS, JS, and image files.

IronPDF makes use of an embedded, full Chromium based web browser renderer to convert HTML to PDF. This allows developers to generate PDFs from HTML, images, and CSS and to work closely with existing web assets and work in parallel with designers during a project.

IronPDF focuses on developer productivity. The Library simplifies many common complex PDF code tasks into convenient C# methods to extract text and images, sign PDFS, edit PDFs with new HTML and more - without the developer needing to study the PDF document standard to understand how to achieve their best result.

Common Library Features

Let us have a look at some of their features.

  • Generating PDF documents from HTML, images and ASPX files
  • Reading PDF text
  • Extracting data and images from PDFs
  • Merging PDF documents
  • Splitting PDFs
  • Manipulating PDFs
  • Adding digital signatures
  • Adding timestamps on signatures
  • PDF Portfolio
  • PDF text extraction
  • PDF attachment extraction
  • PDF image extraction
  • PDF merging
  • PDF splitting
  • Updating of PDF metadata
  • PDF image drawing
  • PDF table creation
  • Importing data
  • Convert PDF text to text, image, HTML and Excel

Compare IronPDF and Spire.PDF

IronPDFSpirePDF
Convert HTML to PDF in C# using IronPDFSpire.PDF for .NET supports converting HTML in C#
URL to PDF in 3 lines of codeComplicated workaround to try to convert from URL
Easy HTML String to PDF conversionCan convert HTML String to PDF
Convert XML to PDFXML not supported for conversion
Icon Fonts (Fontello, Bootstrap, FontAwesome) 14 Core Fonts
Type 1 Fonts
Type 3 Fonts
CJK Fonts
True Type Fonts
Unicode Support
Licenses from $399Licenses from $599


Price Comparison

1. Compare Licenses and Pricing

License optionIronPDFSpirePDF
1 developer, 1 location$399$599
1 developer, unlimited projects, 1 location$699$599
Up to 10 developers, unlimited projects, up to 10 locations$1199$3070
Unlimited developers, unlimited project, unlimited locations$1799No License
1 SaaS/OEM product, up to 50 developers, unlimited locations$1599$8988
Purchase a licenseIronPDF Licensing OptionsSpirePDF Licensing Options

Now, let the code do the talking!


Step 1: Installation

First, we will create a project to test different PDF functions using each software library.

Create an ASP.NET Project

Create an ASP.NET website using the following steps:

  • Open Visual Studio
  • Click File, then New Project
  • Select the "Web" option under Visual C#, when looking in the Project type listbox
  • Select ASP.NET Web Application, as shown below

Figure 1New Project

  • Click OK
  • The next screen appears and from it, select Web Forms as shown below

    Figure 2Web Forms

  • Click OK


2. Install IronPDF Library

There are two main ways to install IronPDF on your PC, they are shown below:

  • NuGet
  • Download the IronPDF library, as will be explained a bit later.

There are essentially three ways to quickly install the IronPDF NuGet package in your Visual Studio projects, they are:

  • Install through Visual Studio
  • Using the Developer Command Prompt
  • Download the NuGet Package directly from NuGet

2.1. Visual Studio

The NuGet Package Manager is used to download and install various packages that you can include in your applications to improve their functionality. One such package is IronPDF. In order to download and install the IronPDF NuGet Package, select the Project Menu, or right click your project in the Solution Explorer. A screenshot of each is shown next.

Figure 4Right click Solution Explorer

Browse for the IronPDF package and install it as shown below.

Figure 5Install IronPDF NuGet Package

2.2. Developer Command Prompt

You can also install the IronPDF NuGet package by using the Developer Command Prompt. The next few steps explain how.

  • Search for your Developer Command Prompt – usually found under the Visual Studio program folder
  • Type in the following command:
  • PM > Install-Package IronPdf
  • Press Enter
  • The package will be installed.
  • Reload your Visual Studio project

2.3. Download the NuGet Package from NuGet

The following steps enable you to download IronPDF directly from NuGet:

2.4. Install IronPDF by downloading the library

The second way to install IronPDF is by downloading it directly by clicking here to download IronPDF.dll.

Figure 6Download IronPDF library

Reference the Library in your project by using the next steps:

  • Right click the Solution in the Solution Explorer
  • Select References
  • Browse for the IronPDF.dll library
  • Click OK


Spire PDF DLL Download

There are three ways to install the SpirePDF NuGet package in your Visual Studio projects, they include:

  • Install through Visual Studio
  • Using the Developer Command Prompt
  • Download the NuGet Package directly from the SpirePDF NuGet website

In Visual Studio, search for SpirePDF and install the relevant packages, as shown next. (The steps are similar to what was shown earlier)

Figure 7SpirePDF

Or, in the Developer Command Prompt (as shown previously, enter the following command)

Install-Package Spire.PDF -Version 6.9.16

Or, download it directly from their website: https://www.e-iceblue.com/Download/download-pdf-for-net-now.html

You will have to register an account.

If everything went well, you should be all set up to start using the libraries.


3. Create a PDF from an Existing URL

The following code downloads a webpage and converts it to a PDF document. I have included page header and page footer options as well.

3.1. PDF from URL with IronPDF

The code that follows makes use of IronPDF to create a PDF from a URL - in this case: the description of the PDF format on Wikipedia. Customer headers and Footers are also included.

private void ExistingWebURL()
{
    var Renderer = new IronPdf.HtmlToPdf();
    var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");

    // Create a PDF from an existing HTML
    Renderer.PrintOptions.MarginTop = 50;  //millimetres
    Renderer.PrintOptions.MarginBottom = 50;
    Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;
    Renderer.PrintOptions.Header = new SimpleHeaderFooter()
    {
        CenterText = "{pdf-title}",
        DrawDividerLine = true,
        FontSize = 16
    };
    Renderer.PrintOptions.Footer = new SimpleHeaderFooter()
    {
        LeftText = "{date} {time}",
        RightText = "Page {page} of {total-pages}",
        DrawDividerLine = true,
        FontSize = 14
    };

    Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;

    Renderer.PrintOptions.EnableJavaScript = true;
    Renderer.PrintOptions.RenderDelay = 500; //milliseconds

    PDF.SaveAs("wikipedia.pdf");
}
private void ExistingWebURL()
{
    var Renderer = new IronPdf.HtmlToPdf();
    var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");

    // Create a PDF from an existing HTML
    Renderer.PrintOptions.MarginTop = 50;  //millimetres
    Renderer.PrintOptions.MarginBottom = 50;
    Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;
    Renderer.PrintOptions.Header = new SimpleHeaderFooter()
    {
        CenterText = "{pdf-title}",
        DrawDividerLine = true,
        FontSize = 16
    };
    Renderer.PrintOptions.Footer = new SimpleHeaderFooter()
    {
        LeftText = "{date} {time}",
        RightText = "Page {page} of {total-pages}",
        DrawDividerLine = true,
        FontSize = 14
    };

    Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print;

    Renderer.PrintOptions.EnableJavaScript = true;
    Renderer.PrintOptions.RenderDelay = 500; //milliseconds

    PDF.SaveAs("wikipedia.pdf");
}
Private Sub ExistingWebURL()
	Dim Renderer = New IronPdf.HtmlToPdf()
	Dim PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format")

	' Create a PDF from an existing HTML
	Renderer.PrintOptions.MarginTop = 50 'millimetres
	Renderer.PrintOptions.MarginBottom = 50
	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print
	Renderer.PrintOptions.Header = New SimpleHeaderFooter() With {
		.CenterText = "{pdf-title}",
		.DrawDividerLine = True,
		.FontSize = 16
	}
	Renderer.PrintOptions.Footer = New SimpleHeaderFooter() With {
		.LeftText = "{date} {time}",
		.RightText = "Page {page} of {total-pages}",
		.DrawDividerLine = True,
		.FontSize = 14
	}

	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Print

	Renderer.PrintOptions.EnableJavaScript = True
	Renderer.PrintOptions.RenderDelay = 500 'milliseconds

	PDF.SaveAs("wikipedia.pdf")
End Sub
VB   C#

The output file contains 12 pages and it rendered JavaScript and CSS exceptionally well. The resulting output is shown below:

Figure 9IronPDF Tiger Wiki Page

3.2. PDF from URL with SpirePDF

Generating a PDF from a URL is a seemingly simple conversion, as we saw above. But due to a number of factors, our engineering team had difficulty trying to accomplish it with SpirePDF. There is not much documentation available on this, and as developers we tried to find a workaround.

In order to accomplish this, we believe that you have to download and install more tools, as referenced here: http://www.e-iceblue.com/Download/download-pdf-for-net-now.html

We still haven't figured it out. Instead, here is a code segment for a Console Application that you could use to achieve this after you have gone through the whole rigmarole of steps:

//Create a pdf document.
PdfDocument doc = new PdfDocument();

PdfPageSettings setting = new PdfPageSettings();

setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
htmlLayoutFormat.IsWaiting = true;

String url = "https://www.wikipedia.org/";

Thread thread = new Thread(() =>
{ doc.LoadFromHTML(url, false, false, false, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//Save pdf file.
doc.SaveToFile("output-wiki.pdf");
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start("output-wiki.pdf");
//Create a pdf document.
PdfDocument doc = new PdfDocument();

PdfPageSettings setting = new PdfPageSettings();

setting.Size = new SizeF(1000, 1000);
setting.Margins = new Spire.Pdf.Graphics.PdfMargins(20);

PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
htmlLayoutFormat.IsWaiting = true;

String url = "https://www.wikipedia.org/";

Thread thread = new Thread(() =>
{ doc.LoadFromHTML(url, false, false, false, setting, htmlLayoutFormat); });
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
//Save pdf file.
doc.SaveToFile("output-wiki.pdf");
doc.Close();
//Launching the Pdf file.
System.Diagnostics.Process.Start("output-wiki.pdf");
'Create a pdf document.
Dim doc As New PdfDocument()

Dim setting As New PdfPageSettings()

setting.Size = New SizeF(1000, 1000)
setting.Margins = New Spire.Pdf.Graphics.PdfMargins(20)

Dim htmlLayoutFormat As New PdfHtmlLayoutFormat()
htmlLayoutFormat.IsWaiting = True

Dim url As String = "https://www.wikipedia.org/"

Dim thread As New Thread(Sub()
	doc.LoadFromHTML(url, False, False, False, setting, htmlLayoutFormat)
End Sub)
thread.SetApartmentState(ApartmentState.STA)
thread.Start()
thread.Join()
'Save pdf file.
doc.SaveToFile("output-wiki.pdf")
doc.Close()
'Launching the Pdf file.
System.Diagnostics.Process.Start("output-wiki.pdf")
VB   C#

3.3. Code Comparison

IronPDF needed three lines of code (if you include the SaveAs method at the bottom of the code segment as well), but otherwise just two lines were needed:

var Renderer = new IronPdf.HtmlToPdf();
var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");
var Renderer = new IronPdf.HtmlToPdf();
var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");
Dim Renderer = New IronPdf.HtmlToPdf()
Dim PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format")
VB   C#

Quick and to the point. As you may have noticed, the code doesn’t make use of a FileStream or any additional .NET objects; RenderUrlAsPdf method handles all the complexities of the .NET Framework behind the scenes.

SpirePDF, on the other hand, made it very complicated to achieve the task of converting URL to PDF and required creative workarounds.


4. Convert HTML String to PDF

The following examples make use of IronPDF and SpirePDF to create a PDF document with a supplied HTML string.

4.1. PDF from HTML String with IronPDF

The following code makes use of IronPDF to create a PDF containing HTML input.

private void HTMLString()
{
    var Renderer = new IronPdf.HtmlToPdf();
    var PDF = Renderer.RenderHtmlAsPdf("<h1>Hi there IronPdf</h1>");

    Renderer.PrintOptions.Footer = new HtmlHeaderFooter() { HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>" };

    var OutputPath = "HtmlToPDF.pdf";
    PDF.SaveAs(OutputPath);
    Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen;
}
private void HTMLString()
{
    var Renderer = new IronPdf.HtmlToPdf();
    var PDF = Renderer.RenderHtmlAsPdf("<h1>Hi there IronPdf</h1>");

    Renderer.PrintOptions.Footer = new HtmlHeaderFooter() { HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>" };

    var OutputPath = "HtmlToPDF.pdf";
    PDF.SaveAs(OutputPath);
    Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen;
}
Private Sub HTMLString()
	Dim Renderer = New IronPdf.HtmlToPdf()
	Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Hi there IronPdf</h1>")

	Renderer.PrintOptions.Footer = New HtmlHeaderFooter() With {.HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"}

	Dim OutputPath = "HtmlToPDF.pdf"
	PDF.SaveAs(OutputPath)
	Renderer.PrintOptions.CssMediaType = PdfPrintOptions.PdfCssMediaType.Screen
End Sub
VB   C#

4.2. PDF from HTML String with SpirePDF

The following code uses SpirePDF to create a PDF containing HTML text.

private void HTMLString()
{
    Document document = new Document();
    document.LoadFromFile("sample.htm", FileFormat.Html, XHTMLValidationType.None);

    //Save html to PDF.
    document.SaveToFile("Sample.pdf", FileFormat.PDF);
}
private void HTMLString()
{
    Document document = new Document();
    document.LoadFromFile("sample.htm", FileFormat.Html, XHTMLValidationType.None);

    //Save html to PDF.
    document.SaveToFile("Sample.pdf", FileFormat.PDF);
}
Private Sub HTMLString()
	Dim document As New Document()
	document.LoadFromFile("sample.htm", FileFormat.Html, XHTMLValidationType.None)

	'Save html to PDF.
	document.SaveToFile("Sample.pdf", FileFormat.PDF)
End Sub
VB   C#

4.3. Code Comparison

SpirePDF seems to only be able to load HTML files (as far as I could deduce) by using the LoadFromFile method and then makes use of the SaveToFile call to send an HTML file to be output as a PDF.

IronPDF uses the RenderHtmlAsPdf to render the given HTML string in PDF format.


5. Convert ASPX Pages to PDF

The next IronPDF and SpirePDF code creates a PDF document from an ASPX page.

5.1. ASPX to PDF with IronPDF

The following code makes use of IronPDF to create a PDF document from an ASPX file.

protected void Page_Load(object sender, EventArgs e)
{

    IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
protected void Page_Load(object sender, EventArgs e)
{

    IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

	IronPdf.AspxToPdf.RenderThisPageAsPdf()
End Sub
VB   C#

5.2. ASPX to PDF with SpirePDF

The following code would convert an ASPX file to PDF.

protected void Page_Load(object sender, EventArgs e)
{
    PdfDocument pdf = new PdfDocument();
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    this.RenderControl(htw);
    //string sourceCode = sw.ToString();
    string url=Request.Url.AbsoluteUri;
    Thread thread = new Thread(() =>
    {
        PdfPageSettings settings = new PdfPageSettings();
        PdfHtmlLayoutFormat format = new PdfHtmlLayoutFormat();
        pdf.LoadFromHTML(url, false, true, true, settings, format);
        //pdf.LoadFromHTML(Request.Url.AbsoluteUri, false, true, true);
    });
    pdf.SaveToHttpResponse("NameOfFile.pdf", Response, HttpReadType.Save);
}
protected void Page_Load(object sender, EventArgs e)
{
    PdfDocument pdf = new PdfDocument();
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    this.RenderControl(htw);
    //string sourceCode = sw.ToString();
    string url=Request.Url.AbsoluteUri;
    Thread thread = new Thread(() =>
    {
        PdfPageSettings settings = new PdfPageSettings();
        PdfHtmlLayoutFormat format = new PdfHtmlLayoutFormat();
        pdf.LoadFromHTML(url, false, true, true, settings, format);
        //pdf.LoadFromHTML(Request.Url.AbsoluteUri, false, true, true);
    });
    pdf.SaveToHttpResponse("NameOfFile.pdf", Response, HttpReadType.Save);
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
	Dim pdf As New PdfDocument()
	Dim sw As New StringWriter()
	Dim htw As New HtmlTextWriter(sw)
	Me.RenderControl(htw)
	'string sourceCode = sw.ToString();
	Dim url As String=Request.Url.AbsoluteUri
	Dim thread As New Thread(Sub()
		Dim settings As New PdfPageSettings()
		Dim format As New PdfHtmlLayoutFormat()
		pdf.LoadFromHTML(url, False, True, True, settings, format)
		'pdf.LoadFromHTML(Request.Url.AbsoluteUri, false, true, true);
	End Sub)
	pdf.SaveToHttpResponse("NameOfFile.pdf", Response, HttpReadType.Save)
End Sub
VB   C#

There are some caveats though: It may sometimes end up creating a blank PDF as Forms Authentication Membership is not supported.


6. Convert XML to PDF

The following code takes XML and converts it to a PDF document

6.1. XML to PDF with IronPDF

private void XMLtoPDF(string XSLT, string XML)
{
    XslCompiledTransform transform = new XslCompiledTransform();
    using(XmlReader reader = XmlReader.Create(new StringReader(XSLT)))
    {
        transform.Load(reader);
    }

    StringWriter results = new StringWriter();
    using(XmlReader reader = XmlReader.Create(new StringReader(XML)))
    {
        transform.Transform(reader, null, results);
    }

    IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
    Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("XMLtoPDF.pdf");
}
private void XMLtoPDF(string XSLT, string XML)
{
    XslCompiledTransform transform = new XslCompiledTransform();
    using(XmlReader reader = XmlReader.Create(new StringReader(XSLT)))
    {
        transform.Load(reader);
    }

    StringWriter results = new StringWriter();
    using(XmlReader reader = XmlReader.Create(new StringReader(XML)))
    {
        transform.Transform(reader, null, results);
    }

    IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
    Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("XMLtoPDF.pdf");
}
Private Sub XMLtoPDF(ByVal XSLT As String, ByVal XML As String)
	Dim transform As New XslCompiledTransform()
	Using reader As XmlReader = XmlReader.Create(New StringReader(XSLT))
		transform.Load(reader)
	End Using

	Dim results As New StringWriter()
	Using reader As XmlReader = XmlReader.Create(New StringReader(XML))
		transform.Transform(reader, Nothing, results)
	End Using

	Dim Renderer As New IronPdf.HtmlToPdf()
	Renderer.RenderHtmlAsPdf(results.ToString()).SaveAs("XMLtoPDF.pdf")
End Sub
VB   C#

6.2. XML to PDF with SpirePDF

SpireDoc only supports converting Office OpenXML to PDF.


Compare Offerings

7. Licensing and Support

Pricing is most likely the number one deciding factor when deciding which product to buy. In the table, I'll quickly highlight the various options for IronPDF and SpirePDF.

See the Pricing Comparison Chart

7.1. Support and Updates

Next, let’s compare the support and updates for Iron Software and SpirePDF.

IronPDF Support & Updates

  • Iron Software offers a money-back guarantee.
  • IronPDF is free for development, and can be deployed using a free 30-day trial license key.
  • Iron Software provides one year of support & monthly release updates free with every license.
  • Extension options include:
    • Yearly subscriptions
    • 4-year pack at 40% discount
  • Iron Software provides support through their development team, with tickets answered by the engineers who built the product.
  • Product Feature Requests can be made via Support.
  • Initial license purchases provide a perpetual license for the current version. One-time purchase, lifetime coverage.
  • Product Updates coverage allows for update to the latest version at any time while coverage is valid.

SpirePDF Support & Updates

The following support services are available:

  • 14-day Money Back guarantee
  • 30-day Free Trial
  • 1 Year Free Update and Free Prior Technology Support
  • Free Customized Service for OEM users


Tutorial Quick Access

Explore the IronPDF Object Reference

Explore the Object Reference for IronPDF C# Library, including details of all of IronPDF’s features, classes, method fields, namespaces, and enums.

View the Object Reference