Winnovative Software Logo

 HTML to PDF Converter - Excel Library - ASP.NET Charts - RTF to PDF Converter
 PDF Merge and Split - PDF Security - PDF Viewers - PDF to Text - Images Extractor

Skip Navigation Links

HTML to PDF Converter Library 9.12 for .NET

The Winnovative HTML to PDF Converter library for .NET can be linked into any .NET application, either ASP.NET web sites or Windows Forms and WPF applications, to convert URLs, HTML strings and streams to a PDF document or to an image.

You can use the 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.

The converter offers full support for HTML tags and CSS, page breaks control with CSS styles, automatically repeating HTML table header on each PDF page, live URLs and internal links in PDF, automatically generated bookmarks, HTML in the headers and footers.

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 3.5, .NET 4.0 and .NET 4.5 frameworks and with Windows Azure Cloud applications.

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.

Main Features

HTML to PDF Converter for .NET Box
Easy integration, no installation or setup is necessary on the server
Delivered as a single strong named .NET assembly (can be installed in GAC)
Compatible with .NET 2.0, .NET 3.5 and .NET 4.0 and later frameworks
Compatible with Windows Azure Cloud applications
Can be deployed on the server by simple copy (xcopy deployment support)
Can be used from ASP.NET, Windows Forms, WPF, Web Service or Console applications
The same assembly can be used both on 32-bit and 64-bit Windows servers
Convert web pages, HTML strings and streams to PDF files or PDF streams in memory
Convert a web pages, HTML strings and streams to various image formats
Convert multiple web pages, HTML strings and streams into the same PDF document
Place the HTML content anywhere in a PDF page as HtmlToPdfElement objects
Designed and tested for multithreaded environments and high traffic websites
Generate PDF documents compliant with PDF/A, PDF/X and PDF/SiqQ standards
Full support for Unicode, complex script and right to left Asian languages (Arabic, Hebrew, CJK)
Set PDF page size to a standard size (A4, A3, etc) or to a custom size
Set PDF page orientation (portrait or landscape)
Set PDF document margins
Set PDF streams compression level to reduce the PDF document size
Set JPEG compression level for images to reduce the PDF document size
Add HTML, text, images and page numbers in header and footer
Show/hide header and footer on odd/even pages
Control of the page breaks using CSS styles
Force page breaks with page-break-before:always and page-break-after:always CSS styles
'Keep Together' feature with page-break-inside:avoid CSS style
Option to avoid cutting off texts between PDF pages
Option to avoid cutting off images between PDF pages
Repeat the header and footer of HTML tables with display:table-header-group CSS style
Options to selectively exclude HTML regions from the rendered PDF document
Options to convert a given element from the HTML document
Support for Web Fonts to allow usage in HTML of fonts which are not installed on server
Support for Media Type rules to have different styles for screen and for print
Options to shrink or stretch the HTML content to fit the PDF document page width
Option to automatically resize the PDF page to a custom size to fit the HTML content
Convert HTTP links from HTML to HTTP links in PDF pointing to external resources
Convert internal links from HTML to internal links in PDF to easily create tables of contents
Automatically generated bookmarks for a specified list of HTML tags
Get the position in PDF, by HTML ID or by HTML tag name, of any HTML element
Embed true type fonts into the rendered PDF
Append or prepend external PDF files to the conversion result
Password protect, allow/deny printing, editing, copying of the generated PDF document
Set the PDF document properties like author, title, subject, keywords, creation date, etc.
Enable/disable JavaScript in rendered web page during conversion
Server authentication support (e.g IIS Integrated Windows Authentication)
Send custom HTTP headers when the web page is requested by the converter
Send custom HTTP cookies when the web page is requested by the converter
Support for accessing the web page to convert by GET or POST requests
C# and VB.NET full samples for ASP.NET and Windows Forms

Code Sample

    /// <summary>
    /// Convert the HTML code from the specified URL to a PDF document
        and send the document to the browser
    /// </summary>
    private void ConvertURLToPDF()
        string urlToConvert = textBoxWebPageURL.Text.Trim();

        // Create the PDF converter. Optionally the HTML viewer width can
            be specified as parameter
        // The default HTML viewer width is 1024 pixels.
        PdfConverter pdfConverter = new PdfConverter();

        // set the license key - required
        pdfConverter.LicenseKey = "R8nYyNnI2MjRxtjI29nG2drG0dHR0Q==";

        // set the converter options - optional
        pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
        pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
        pdfConverter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;

        // set if header and footer are shown in the PDF - optional - default
            is false 
        pdfConverter.PdfDocumentOptions.ShowHeader = cbAddHeader.Checked;
        pdfConverter.PdfDocumentOptions.ShowFooter = cbAddFooter.Checked;
        // set if the HTML content is resized if necessary to fit the PDF
            page width - default is true
        pdfConverter.PdfDocumentOptions.FitWidth = cbFitWidth.Checked;

        // set the embedded fonts option - optional - default is false
        pdfConverter.PdfDocumentOptions.EmbedFonts = cbEmbedFonts.Checked;
        // set the live HTTP links option - optional - default is true
        pdfConverter.PdfDocumentOptions.LiveUrlsEnabled = cbLiveLinks.Checked;

        // set if the JavaScript is enabled during conversion to a PDF - default
            is true
        pdfConverter.JavaScriptEnabled = cbClientScripts.Checked;

        // set if the images in PDF are compressed with JPEG to reduce the
            PDF document size - default is true
        pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = cbJpegCompression.Checked;

        // enable auto-generated bookmarks for a specified list of HTML selectors
            (e.g. H1 and H2)
        if (cbBookmarks.Checked)
            pdfConverter.PdfBookmarkOptions.HtmlElementSelectors = new string[] { "H1", "H2" };

        // add HTML header
        if (cbAddHeader.Checked)
        // add HTML footer
        if (cbAddFooter.Checked)

        // Performs the conversion and get the pdf document bytes that can
        // be saved to a file or sent as a browser response
        byte[] pdfBytes = pdfConverter.GetPdfBytesFromUrl(urlToConvert);

        // send the PDF document as a response to the browser for download
        System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
        response.AddHeader("Content-Type", "application/pdf");
        if (radioAttachment.Checked)
                    String.Format("attachment; filename=GettingStarted.pdf; size={0}", 
                    String.Format("inline; filename=GettingStarted.pdf; size={0}", 
        // Note: it is important to end the response, otherwise the ASP.NET
        // web page will render its content to PDF document stream