Winnovative HTML to PDF Converter for .NET

Winnovative HTML to PDF Converter library for .NET can be integrated in any .NET application from ASP.NET and MVC web sites to Windows Forms and WPF applications. It allows you to convert in your application URLs, HTML strings and streams to a PDF document, to a bitmap images or to a SVG vector images.

Features list itemFull Support for HTML5 Features like CSS3, SVG and Web Fonts

Winnovative HTML to PDF Converter Box The converter offers full support for HTML tags, HTML5 with CSS3, SVG and Web Fonts, page breaks control, media type rules, repeating HTML table header and footer, hierarchical bookmarks, tables of contents, fillable PDF forms, HTML with page numbering in header and footer.

Features list itemPerfect for Creating Complex PDF reports

You can use the Winovative HTML to PDF Converter for .NET as a general purpose tool for converting web pages and HTML code to PDF and images or you can use it as part of our .NET Reporting Toolkit to easily create PDF reports directly from ASP.NET pages and to benefit from the great power of ASP.NET controls.

Features list itemNo External Dependencies. Easy Integration and Deployment

The HTML to PDF Converter is not using a printer driver and no special settings are necessary on the server in order to get it working. The same assembly works both in 32-bit and 64-bit environments and xcopy deployment on the server is supported. The library is compatible with .NET 2.0, .NET 4.0 and later frameworks.

Features list itemReliable in Multithreaded Environments

The library was designed and tested to work reliably in multithreaded environments and to completely release all the resources used during conversion after each conversion. This makes it suitable for usage in high traffic ASP.NET websites and services running a long period of time without interruption.

Features list itemMuch More than a HTML to PDF Converter

The HTML to PDF converter library can be used to edit existing PDF documents, merge and split PDF documents, fill and save the PDF form in an existing PDF document.

Features list itemComprehensive Demo, Documentation and Code Samples

Winnovative HTML to PDF Converter comes with an impressive set of demo applications covering most of the software features. For each demo we provide the complete .NET source code in C# and VB.NET. Each feature is briefly documented inline in demo application and completely documented in product documentation.

Features list itemFree, Unlimited in Time and Fully Functional Trial Version

The evaluation versions of the development libraries we offer for download are fully functional and unlimited in time. The only difference between the evaluation version and the licensed version is that the evaluation version will insert a demo watermark in the documents it produces.

Features list itemConvenient and Flexible Licensing Model. Redistribution is Allowed.

The Winnovative Software licensing model consists in two types of licenses: the Deployment License can be used in a single application that can be deployed on a single server owned by your company. The Redistributable License can be used in an unlimited number of applications that can be deployed on any number of servers. The Redistributable License can be distributed as part of your applications to your own customers without any additional costs.

DemoDemo DownloadDownload ContactSupport

DownloadCompatibility

Winnovative HTML to PDF Converter for .NET is compatible with any platform which supports .NET Standard 2.0 and above or .NET Framework 4.0 and above, including:

  • .NET Core 7, 6, 5, .NET Standard 2.0 (and above)
  • .NET Framework 4.8.1, 4.7.2, 4.6.1, 4.0 (and above)
  • Windows 32-bit (x86) and 64-bit (x64)
  • Azure Cloud Services and Azure Virtual Machines
  • Web, Console and Desktop applications

For Linux, macOS, Windows, Azure App Service, Xamarin, UWP and other platforms you can use the Cross-Platform PDF Library for .NET which includes the HTML to PDF, Word to PDF, Excel to PDF, PDF to Text, PDF to Image, PDF to HTML and PDF Images Extractor components from Winnovative PDF Toolkit PRO in a single library under an unique namespace.

DownloadSoftware Download

The evaluation version of the Winnovative HTML to PDF Converter can be downloaded as a zip archive. The software does not need installation. You can simply extract the archive into a folder and reference the .NET assembly in your project. You must read and accept our End User License Agreement before you download the software. Downloading the software from our website implies that you agreed the terms and conditions.

DownloadGetting 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 WnvHtmlToPdf.dll assembly from root folder of the ZIP package for .NET Framework or alternatively the NuGet Logo ImageWinnovative.HtmlToPdf NuGet packages.

In projects targeting the .NET Core platform you can reference the NuGet Logo ImageWinnovative.HtmlToPdf.NetCore NuGet package or alternatively the WnvHtmlToPdf_NetCore.dll from the Bin folder of the ZIP package for .NET core, but in this case you also have to manually reference the Winnovative.HtmlToPdf.NetCore package dependencies.

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

Code Sample IconC# 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.

The server IP address is assigned during server installation and it can be omitted from HtmlToPdfConverter constructor if the server was installed on the localhost IP address 127.0.0.1 . There are also variants of the constructor accepting an URL instead of IP address if the server was installed as a web service in Azure or in IIS.

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

// add this using statement at the top of your C# file
using Winnovative;

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

// 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 Winnovative !", null, "HtmlToFile.pdf");

// convert HTML page from URL to a PDF file
string htmlPageURL = "http://www.winnovative-software.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.

// 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 Winnovative !", 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.winnovative-software.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.

// 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 Winnovative !", 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.

// 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 Winnovative !", 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();

HTML to PDFHTML to PDF Converter Features

  • Easy integration, no installation required
  • Designed and tested for multithreaded environments
  • Does not require IE WebBrowser or any third party tools
  • Compatible with .NET 2.0, .NET 4.0 and .NET 4.5 frameworks
  • 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 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

HTML to PDFHTML to PDF Code Sample

protected void convertToPdfButton_Click(object sender, EventArgs e)
{
    // 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(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();
}