EvoPdf Classic HTML to PDF Converter for .NET
EvoPdf Classic · HTML to PDF

EVO Classic HTML to PDF for .NET

Classic v14.0 · Windows, .NET Framework 2.0+ and .NET 6–10 · Evaluate without registration — demo mode by default (watermarked) · Licensed with the HTML to PDF Converter license or EVO PDF Toolkit

$dotnet add package EvoPdf.HtmlToPdf

Windows · .NET Framework 2.0+ and .NET 6–10 (.NET Standard 2.0) · the EvoPdf metapackage bundles the Classic HTML to PDF library

Program.csC#
using EvoPdf;

var converter = new HtmlToPdfConverter();
byte[] pdf = converter.ConvertUrl(
    "https://www.evopdf.com");
File.WriteAllBytes("page.pdf", pdf);

// or from an HTML string, with a base URL
pdf = converter.ConvertHtml(
    "<b>Hello World</b>", "https://www.evopdf.com");
Classic API: EvoPdf namespace, one converter class, synchronous calls. API reference →
  • Windows 10 / 11 / Server 2016–2025
  • .NET Framework 2.0 – 4.8.1
  • .NET 6 → 10, .NET Standard 2.0
  • Azure Cloud Services & Virtual Machines
  • Web, console and desktop applications
Features

What the HTML to PDF component does

  • Easy integration, no installation or setup is required on server
  • Designed and tested for multithreaded environments
  • Does not require IE WebBrowser or any third party tools
  • Compatible with .NET Framework and .NET Core Runtime
  • Compatible with Windows Azure Cloud applications
  • Can be deployed on the server by simple xcopy deployment
  • Works both in 32-bit and 64-bit environments
  • Convert web pages, HTML strings to PDF files or in memory
  • Convert web pages, HTML strings to raster image formats
  • Convert web pages, HTML strings to SVG vector images
  • Support for HTML5 features like CSS3, SVG and Web Fonts
  • Convert HTML with SVG and Web Fonts to PDF
  • Different styles for screen and print using @media rules
  • Merge multiple web pages into the single PDF document
  • Convert only a selected part of the HTML document
  • Generate PDF/A and PDF/X compliant documents
  • Generate CMYK and Gray Scale PDF documents
  • Full support for Unicode and right to left languages
  • Set PDF page size to a standard (A4, etc.) or a custom size
  • Set PDF page orientation and PDF document margins
  • Set JPEG compression level for images in PDF document
  • Add HTML content and page numbers in header and footer
  • Add page numbering in header and footer HTML
  • Control header and footer visibility in each PDF page
  • Add header and footer to existing PDF documents
  • Auto resize header and footer to adapt to content
  • Control page breaks in PDF using standard CSS styles
  • Control page breaks in PDF using API
  • 'Keep Together' feature with page-break-inside:avoid
  • Avoid page breaks inside HTML elements using API
  • Option to avoid cutting off images between PDF pages
  • Add content in PDF pages background during conversion
  • Add content over PDF page main content during conversion
  • Repeat the HTML table header and footer in PDF pages
  • Place and resize the HTML content anywhere in a PDF page
  • Shrink or stretch the HTML content to fit the PDF page
  • Automatically resize the PDF page to fit the HTML content
  • Convert HTTP links from HTML to HTTP links in PDF
  • Convert internal links from HTML to internal links in PDF
  • Auto create a bookmarks hierarchy from heading tags
  • Select in HTML the elements to bookmark
  • Select in API the elements to bookmark
  • Auto create a table of contents from heading tags
  • Define in HTML the elements to include in table of contents
  • Auto create a live PDF form from a HTML form
  • Define in HTML the elements to become fields in PDF form
  • Get the location in PDF for a set of selected HTML elements
  • Embed true type fonts into the rendered PDF for portability
  • Append or prepend external PDF files to conversion result
  • Password protect and set permissions of the PDF document
  • Add a digital signature to generated PDF document
  • Set the PDF document properties like title, subject, etc.
  • Enable or disable JavaScript during conversion
  • HTTP authentication support (IIS Windows Authentication)
  • Use current user credentials for NTLM authentication
  • Support for access through a HTTP or SOCKS Proxy
  • Access the HTML page with GET or POST HTTP methods
  • Add HTTP headers when the HTML page is requested
  • Add cookies when the HTML page is requested
  • Execute a JavaScript when the PDF document is opened
  • Go to a page when the PDF document is opened
  • Open the print dialog when the PDF document is opened
  • Set the zoom level when the PDF document is opened
  • Support for Flash and other extensions
  • Add file links and attachments to generated PDF document
  • Add text notes to generated PDF document
  • Add watermarks and stamps to generated PDF document
  • Add graphic elements to generated PDF document
  • Add image elements to generated PDF document
  • Add text elements to generated PDF document
  • Edit existing PDF document
  • Merge multiple PDF documents in a single PDF document
  • Split a PDF document in multiple PDF documents
  • Fill PDF forms and save the filled PDF document
  • C# and VB.NET samples for ASP.NET, Windows Forms
  • Sample code for ASP.NET MVC with Razor engine
  • Sample code for a Windows Azure Cloud Service
  • Full documentation for all the product features
Documented, with code

Every feature explained with its C# code

The product documentation walks through each capability with the exact C# code, from the converter options to bookmarks, forms and PDF editing. The evaluation package ships the same code as runnable demo projects.

  • Getting started with the converterC# code
  • HTML content destination and scalingC# code
  • Merge multiple HTML pages into one PDFC# code
  • Merge HTML with existing PDF documentsC# code
  • Convert only part of an HTML pageC# code
  • Repeat table header and footerC# code
  • Pages with authentication or through a proxyC# code
  • BookmarksC# code
  • PDF formsC# code
  • Internal links, file links and attachmentsC# code
  • HTML to raster image and SVGC# code
  • Merge, split, stamp and fill PDF documentsC# code
In detail

EVO Classic HTML to PDF for .NET — how it works

EVO Classic HTML to PDF Converter for .NET offers full support for HTML tags, CSS styles, SVG vector graphics, Canvas, Web Fonts, JavaScript, page breaks control with CSS styles, repeating HTML table header and footer in PDF pages, live URLs and internal links in PDF, automatically generated hierarchical bookmarks and table of contents, HTML in the headers and footers.

The library is more than a HTML to PDF converter. You can also use it to create, merge, split, edit and fill existing PDF documents.

EVO Classic HTML to PDF Converter

EVO Classic HTML to PDF Converter for .NET can be used to convert HTML to PDF, images and SVG in applications targeting .NET Framework, .NET Core and .NET Standard. The Classic HTML to PDF Converter is built on a proven rendering engine that has demonstrated efficiency, reliability and stability over many years of real-world use with a small footprint and low resource requirements.

It is well suited for environments where minimal space and compute usage are essential, even if it does not fully support the very latest CSS or JavaScript features when compared to the EvoPdf Next converter. The converter offers full support for HTML tags, CSS styles, SVG vector graphics, page breaks control with CSS styles, automatically repeated HTML table header on each PDF page, live URLs and internal links in PDF, automatically generated bookmarks, HTML in the headers and footers, Unicode and right to left text, PDF merge, split and edit.

There are separate libraries for the .NET Framework and for modern .NET platforms running on Windows. The library for the .NET Framework is compatible with .NET 2.0, .NET 4.0 and later runtimes. The library for .NET was built for .NET Standard 2.0 and is compatible with platforms such as .NET 6, .NET 8 and .NET 10.

For applications that need to run on both Windows and Linux platforms, the EvoPdf Next HTML to PDF Converter for .NET provides a newer and highly accurate rendering engine designed for modern HTML, CSS and JavaScript content.

The full EvoPdf Next Library for .NET can be used on Windows, Linux, Azure and Docker platforms to create, edit and merge PDF documents, convert HTML to PDF or images, convert Word, Excel, RTF and Markdown to PDF, extract text and images from PDFs, search text in PDFs and convert PDF pages to images.

User Guide

Compatibility

The compatibility list includes the following .NET versions, platforms and application types:

  • .NET Framework 2.0, 3.5, 4.0 and above
  • .NET 10, 9, 8, 7, 6 and .NET Standard 2.0
  • Windows platforms
  • Azure Cloud Services and Azure Virtual Machines
  • Web, Console and Desktop applications

The new EvoPdf Next Library can be used to convert HTML to PDF on both Windows and Linux platforms, including Azure App Service and Docker containers. It also allows you to convert Word, Excel, RTF and Markdown to PDF, extract text and images from PDFs, search text in PDFs and convert PDF pages to images.

The evaluation package for EvoPdf HTML to PDF Converter can be downloaded as a zip archive containing the product libraries and sample projects compatible with .NET Framework 2.0, 3.5, 4.0 and above, .NET 10, 9, 8, 7, 6 and .NET Standard 2.0 on Windows platforms.

EvoPdf HTML to PDF converter library is also available as a NuGet package that can be referenced in your .NET projects.

Getting Started

You can quickly start with the demo applications from the Samples folder of the downloaded package or you can integrate the library in your own project. To start with your own project, first add a reference to library.

In projects targeting the .NET Framework platform you can reference directly the EvoHtmlToPdf.dll assembly from root folder of the ZIP package for .NET Framework or alternatively the EvoPdf.HtmlToPdf NuGet packages.

In projects targeting the .NET Core platform you can reference the EvoPdf.HtmlToPdf NuGet package or alternatively the EvoHtmlToPdf_NetCore.dll from the Bin folder of the ZIP package for .NET core, but in this case you also have to manually reference the EvoPdf.HtmlToPdf package dependencies and copy the resource files.

After the reference to library was added to your project you are now ready to start writing code to convert HTML to PDF in your .NET application

C# Code Samples

Copy the C# code lines from the section below to use the HTML to PDF Converter component to create a PDF document from a web page or from a HTML string and save the resulted PDF to a memory buffer for further processing, to a PDF file or send it to browser for download in ASP.NET applications.

At the top of your C# source file add the using EvoPdf; statement to make available the EVO HTML to PDF Converter API for your .NET application.

At a glance

Component
EvoPdf Classic · HTML to PDF
NuGet package
EvoPdf.HtmlToPdf
Namespace
EvoPdf
Main class
HtmlToPdfConverter
Runs on
Windows · .NET Framework 2.0+ · .NET 6–10 (.NET Standard 2.0)
Version
Classic v14.0
License
HTML to PDF Converter license or EVO PDF Toolkit; evaluation without registration
Documentation →
Sample.csC#
// add this using statement at the top of your C# file
using EvoPdf;

To convert a HTML string or an URL to a PDF file you can use the C# code below.

Sample.csC#
// create the converter object in your code where you want to run conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert the HTML string to a PDF file
converter.ConvertHtmlToFile("<b>Hello World</b> from EVO PDF !", null, "HtmlToFile.pdf");

// convert HTML page from URL to a PDF file
string htmlPageURL = "http://www.evopdf.com";
converter.ConvertUrlToFile(htmlPageURL, "UrlToFile.pdf");

To convert a HTML string or an URL to a PDF document in a memory buffer and then save it to a file you can use the C# code below.

Sample.csC#
// create the converter object in your code where you want to run conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert a HTML string to a memory buffer
byte[] htmlToPdfBuffer = converter.ConvertHtml("<b>Hello World</b> from EVO PDF !", null);

// write the memory buffer to a PDF file
System.IO.File.WriteAllBytes("HtmlToMemory.pdf", htmlToPdfBuffer);

// convert an URL to a memory buffer
string htmlPageURL = "http://www.evopdf.com";
byte[] urlToPdfBuffer = converter.ConvertUrl(htmlPageURL);

// write the memory buffer to a PDF file
System.IO.File.WriteAllBytes("UrlToMemory.pdf", urlToPdfBuffer);

To convert in your ASP.NET Core and ASP.NET MVC applications a HTML string or an URL to a PDF document in a memory buffer and then send it for download to browser you can use the C# code below.

Sample.csC#
// create the converter object in your code where you want to run conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert a HTML string to a memory buffer
byte[] htmlToPdfBuffer = converter.ConvertHtml("<b>Hello World</b> from EVO PDF !", null);

FileResult fileResult = new FileContentResult(htmlToPdfBuffer, "application/pdf");
fileResult.FileDownloadName = "HtmlToPdf.pdf";
return fileResult;

To convert in your ASP.NET Web Forms application a HTML string to a PDF document in a memory buffer and then send it for download to browser you can use the C# code below.

Sample.csC#
// create the converter object in your code where you want to run conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert a HTML string to a memory buffer
byte[] htmlToPdfBuffer = converter.ConvertHtml("<b>Hello World</b> from EVO PDF !", null);

HttpResponse httpResponse = HttpContext.Current.Response;
httpResponse.AddHeader("Content-Type", "application/pdf");
httpResponse.AddHeader("Content-Disposition",
    String.Format("attachment; filename=HtmlToPdf.pdf; size={0}",
    htmlToPdfBuffer.Length.ToString()));
httpResponse.BinaryWrite(htmlToPdfBuffer);
httpResponse.End();

EVO HTML to PDF Converter for .NET API allows you to convert a HTML document to PDF in just a few lines a code. The programming interface is also very rich and allows you customize the generated PDF document in various ways. The code below is copied from the Getting Started demo for HTML to PDF Converter that you can find in the Samples folder of the software Zip package.

Sample.csC#
protected void convertToPdfButton_Click(object sender, EventArgs e)
{
    // Create a HTML to PDF converter object with default settings
    HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();

    // Set license key received after purchase to use the converter in licensed mode
    // Leave it not set to use the converter in demo mode

    // Set HTML Viewer width in pixels which is the equivalent in converter of the browser window width
    htmlToPdfConverter.HtmlViewerWidth = int.Parse(htmlViewerWidthTextBox.Text);

    // Set HTML viewer height in pixels to convert the top part of a HTML page 
    // Leave it not set to convert the entire HTML
    if (htmlViewerHeightTextBox.Text.Length > 0)
        htmlToPdfConverter.HtmlViewerHeight = int.Parse(htmlViewerHeightTextBox.Text);

    // Set PDF page size which can be a predefined size like A4 or a custom size in points 
    // Leave it not set to have a default A4 PDF page
    htmlToPdfConverter.PdfDocumentOptions.PdfPageSize = SelectedPdfPageSize();

    // Set PDF page orientation to Portrait or Landscape
    // Leave it not set to have a default Portrait orientation for PDF page
    htmlToPdfConverter.PdfDocumentOptions.PdfPageOrientation = SelectedPdfPageOrientation();

    // Set the maximum time in seconds to wait for HTML page to be loaded 
    // Leave it not set for a default 60 seconds maximum wait time
    htmlToPdfConverter.NavigationTimeout = int.Parse(navigationTimeoutTextBox.Text);

    // Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed
    // Set this property to 0 if you don't need to wait for such asynchcronous operations to finish
    if (conversionDelayTextBox.Text.Length > 0)
        htmlToPdfConverter.ConversionDelay = int.Parse(conversionDelayTextBox.Text);

    // The buffer to receive the generated PDF document
    byte[] outPdfBuffer = null;

    if (convertUrlRadioButton.Checked)
    {
        string url = urlTextBox.Text;

        // Convert the HTML page given by an URL to a PDF document in a memory buffer
        outPdfBuffer = htmlToPdfConverter.ConvertUrl(url);
    }
    else
    {
        string htmlString = htmlStringTextBox.Text;
        string baseUrl = baseUrlTextBox.Text;

        // Convert a HTML string with a base URL to a PDF document in a memory buffer
        outPdfBuffer = htmlToPdfConverter.ConvertHtml(htmlString, baseUrl);
    }

    // Send the PDF as response to browser

    // Set response content type
    Response.AddHeader("Content-Type", "application/pdf");

    // Instruct the browser to open the PDF file as an attachment or inline
    Response.AddHeader("Content-Disposition", String.Format("{0}; filename=Getting_Started.pdf; size={1}",
        openInlineCheckBox.Checked ? "inline" : "attachment", outPdfBuffer.Length.ToString()));

    // Write the PDF document buffer to HTTP response
    Response.BinaryWrite(outPdfBuffer);

    // End the HTTP response and stop the current page processing
    Response.End();
}

EVO HTML to PDF Converter for .NET can be used in any type of .NET application including ASP.NET MVC websites. The code below is copied from the Getting Started demo for MVC that you can find in the Samples\Other\Mvc folder of the software Zip package.

Sample.csC#
[HttpPost]
public ActionResult ConvertHtmlToPdf(FormCollection collection)
{
    // Create a HTML to PDF converter object with default settings
    HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();

    // Set HTML Viewer width in pixels which is the equivalent in converter of the browser window width
    htmlToPdfConverter.HtmlViewerWidth = int.Parse(collection["htmlViewerWidthTextBox"]);

    // Set HTML viewer height in pixels to convert the top part of a HTML page 
    // Leave it not set to convert the entire HTML
    if (collection["htmlViewerHeightTextBox"].Length > 0)
        htmlToPdfConverter.HtmlViewerHeight = int.Parse(collection["htmlViewerHeightTextBox"]);

    // Set PDF page size which can be a predefined size like A4 or a custom size in points 
    // Leave it not set to have a default A4 PDF page
    htmlToPdfConverter.PdfDocumentOptions.PdfPageSize = SelectedPdfPageSize(collection["pdfPageSizeDropDownList"]);

    // Set PDF page orientation to Portrait or Landscape
    // Leave it not set to have a default Portrait orientation for PDF page
    htmlToPdfConverter.PdfDocumentOptions.PdfPageOrientation = SelectedPdfPageOrientation(collection["pdfPageOrientationDropDownList"]);

    // Set the maximum time in seconds to wait for HTML page to be loaded 
    // Leave it not set for a default 60 seconds maximum wait time
    htmlToPdfConverter.NavigationTimeout = int.Parse(collection["navigationTimeoutTextBox"]);

    // Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed
    // Set this property to 0 if you don't need to wait for such asynchcronous operations to finish
    if (collection["conversionDelayTextBox"].Length > 0)
        htmlToPdfConverter.ConversionDelay = int.Parse(collection["conversionDelayTextBox"]);

    string url = collection["urlTextBox"];

    // Convert the HTML page given by an URL to a PDF document in a memory buffer
    byte[] outPdfBuffer = htmlToPdfConverter.ConvertUrl(url);

    // Send the PDF file to browser
    FileResult fileResult = new FileContentResult(outPdfBuffer, "application/pdf");
    fileResult.FileDownloadName = "Getting_Started.pdf";

    return fileResult;
}
Licensing

Perpetual licenses, updates and support included for a year

The HTML to PDF Converter license (450 USD Deployment / 1200 USD Company) covers the Classic and the Next converter; the EVO PDF Toolkit (650 / 1400 USD) covers every component on this site, Classic tools included. The Company License includes redistribution.