HiQPdf Library for .NET - HTML to PDF Converter .NET Core

HiQPdf Library Box The HiQPdf Library for .NET offers you a modern, simple, fast, flexible and powerful tool to create complex and stylish PDF documents in your applications with just a few lines of code.

Using the high quality HTML to PDF conversion engine you can easily design a document in HTML with CSS3, JavaScript, SVG or Canvas and then convert it to PDF preserving the exact content and style.

list itemFast and precise HTML to PDF Conversion Technology

The HiQPdf Library for .NET offers you the fastest and the most precise HTML to PDF conversion technology to use in your Web and Desktop applications. The HTML to PDF Converter can convert to PDF any HTML document or URL that a modern browser can display, preserving all the CSS styles and executing all the JavaScript scripts found in the HTML document.

list itemPowerful and Unique Features on the Market

Besides the common features a HTML to PDF Converter must have, the HiQPdf component has some unique features on the market like the support for web fonts in Web Open Font Format (WOFF), the ability to convert only a selected region of the HTML document or the possibility to overlap multiple HTML documents in the same PDF while preserving the transparent backgrounds and images from the HTML document

list itemConvert Modern HTML5 Documents with CSS3, SVG, Canvas and JavaScript

The HiQPdf HTML to PDF Converter can render HTML documents with last generation content like Scalar Vector Graphics, Canvas and CSS3 styles. The JavaScript engine is fast, can handle complex scripts and exposes in HTML page objects you can use to manually trigger conversion or to determine various information about converter during conversion

list itemSupport for Web Fonts and Web Open Font Format (WOFF)

The HiQPdf HTML to PDF Converter can render HTML documents using Web Fonts in formats like Web Open Font Format (WOFF), TrueType or OpenType with TrueType Outlines. The Web Fonts offer a great flexibility to web designers to create special effects on text in a HTML document because they are not limited anymore to a small set of fonts installed on the client computers displaying the HTML document. The Web Fonts are downloaded on the fly by converter and used to render the HTML document to PDF without installing those fonts on the local machine. The location from where the fonts can be downloaded is given in a CSS3 @font-face rule.

list itemSupport for @media rules in CSS to have different layouts for Screen and Print

Using CSS media types in a HTML document you can have one layout for screen, one for print and one for handheld devices. The @media rule allows different style rules for different media in the same style sheet in a HTML document. By default the HTML to PDF converter will render the HTML document for 'screen', but can layout the document for another media type by simply setting a property in your code.

list itemMuch More Than Just a HTML to PDF Conversion Software

The HTML to PDF conversion engine is the most important feature, but the HiQPdf software is a complete PDF Library for .NET. You can create new PDF documents and add text and images at the desired positions in pages in a traditional manner, open and edit external PDF documents by adding new objects, create PDF documents with interactive forms, fill and submit interactive forms, merge and split PDF documents, extract text and images from PDF documents, search text in PDF documents, rasterize PDF pages to images

list itemNo External Dependencies, Direct Copy Deployment

The HiQPdf Software does not depend on installed browsers, printer drivers, viewers or any other third party software. The HiQPdf Library for .NET can be deployed by simply copying it on the server. It is also possible to install the library in the .NET Framework GAC

list itemASP.NET, MVC and Desktop Samples, Complete Documentation, 24x7 Technical Support

The HiQPdf Library comes with a suite of ASP.NET and Windows Forms samples with complete source code in C# and VB.NET. The main features of the library are well documented and there is a complete API reference in HTML and in Microsoft Help format. If you need more help you can contact our support team at any time. We offer 24x7 technical and sales support

list itemSimple and Flexible Licensing Without Run Time or Deployment Costs

The HiQPdf Software is licensed per developer seat, each developer seat giving to a programmer the right to work on applications using our software component. There are no additional run time or deployment costs charged for using our software component in your applications, the license never expires and includes the software upgrades

DemoDemo DownloadDownload ContactPurchase ContactHelp

The HiQPdf Library for .NET and .NET Core can be integrated in your applications to convert with high accuracy and speed HTML documents and web pages to PDF documents that you can easily distribute and view. This library is compatible with all Windows versions. For other platforms like Linux, MacOS, Azure App Service, Xamarin and many more you can use the Multi-Platform Solution which offers the same features and quality for all platforms, including the most restrictive ones.

HQPdf HTML to PDF Detailed FeaturesDetailed Features

Below you can find a detailed description of the most important features of the HiQPdf HTML to PDF Converter, each feature having also a corresponding sample in the online demo.

  • Convert HTML Documents to PDF, to Image or to SVG - Quickly and accurately convert HTML documents with CSS3, JavaScript, SVG, Canvas and Web Fonts (WOFF) to PDF, SVG or Image. Multiple HTML documents can be laid out in a PDF preserving transparencies. The HTML to Image converter can produce transparent images
  • Convert Only a Selected Region of a HTML Document to PDF - The HiQPdf HTML to PDF converter can be configured to convert only a selected region of the HTML document to PDF. Other HTML to PDF converters on the market can only hide the content around the region to be converted, but the HiQPdf converter will precisely convert the selected HTML region as it would be a standalone document.
  • Convert Multiple HTML Documents into the Same PDF document - A HTML document can be laid out at any position in PDF using a PdfHtml object and multiple objects of this type can be overlapped in multiple layers which can create a very interesting effect when the HTML documents have transparent background.
  • Automatic, Manual or WaitTime HTML Conversion Triggering - By default the conversion is automatically triggered when the HTML is loaded. Because JavaScript can continue execution after load it is possible to manully trigger conversion with a call from JavaScript or to wait a constant interval before triggering conversion.
  • Automatically Generated Outlines and Links - The HTML to PDF converter engine can automatically generate outlines for the HTML elements selected by a list of CSS selectors. The HTTP and internal links from HTML are automatically converted to to HTTP and internal links in PDF
  • Control PDF page breaks with page-break CSS attributes in HTML - Use page-break-before:always in HTML to force a page break right before the element, page-break-after:always to force a page break right after the element and page-break-inside:avoid to avoid cutting off the element between PDF pages if possible
  • Set PDF Background Layer during HTML to PDF Conversion - Before layouting the content in the PDF page the converter will raise the PageLayoutingEvent event. The event transmits a PdfPage object that can be used to layout PDF objects in page before the main HTML content is laid out
  • Repeat HTML Table Header and Footer on Each PDF Page - When the 'display: table-header-group' is present in the HTML table thead tag style the thead content will be automatically repeated on all the PDF pages.
    When the 'display: table-footer-group' is present in the HTML table tfoot tag style the tfoot content will be automatically repeated on all the PDF pages.
  • Retrieve Detailed Info About the Laid Out HTML Elements - The HTML to PDF converter can retrieve detailed information about the HTML elements selected by a list of CSS selectors. You can find the HTML element bounds in PDF, HTML element ID, HTML code, CSS class, the HTML tag and the text if available
  • HTTP Authentication, HTTP Headers, HTTP Cookies and Proxies - The HTML converters can resolve NTLM authentication by setting the username and password, can transmit custom HTTP headers and cookies to the web server when accessing a web page and can get through proxies when the proxy parameters are set
  • Use HTTP GET or POST Requests to Access the HTML to Convert - When converting a HTML document from a given URL, the HTML to PDF converter will access the document using the GET HTTP method by default, but it can be configured to access the web page to convert using the POST HTTP method and to transmit a set of fields to the web server
  • Create PDF/A and PDF/X Standards Compliant Documents - By default the HiQPdf library creates documents compliant to PDF 1.4 standard, but it can be easily configured to create PDF documents compliant to PDF/A standard for long term archiving and to PDF/X standard to facilitate the graphics exchange
  • Encrypt, Password Protect and Digitally Sign PDF Documents - The HiQPdf library includes a set of security features which allow you to set restrictions on the created PDF documents like forbidding printing or content copying, password protect the created PDF documents with user and owner passwords and digitally sign the created PDF documents
  • Create, Load, Fill, Save or Submit Interactive PDF Forms - The HiQPdf library can create or load PDF documents with interactive forms and set a submit action for the form. After a PDF document containing a form was loaded, it is possible to fill the form fields with values and then save the modified PDF document
  • Add HTML, Text, Image and Graphic Objects to PDF - The HiQPdf library can layout PDF objects like text, images and graphics in a PDF document in a classic manner at a given position in a PDF page. It is interesting that the HTML can be treated as a drawable PDF object and can be laid out at any position in PDF
  • Create PDF Documents with Outlines, Links and Attachments - Using HiQPdf library you can create a hierarchy of outlines in the PDF document, you can create internal or URI links in PDF pages and you can attach files and streams to the generated PDF document
  • Load and Edit External PDF Documents - With the HiQPdf software can not only create new PDF documents but you can also load and edit external PDF documents. The editing is limited to adding PDF objects on the top of the existing content. It is not possible to change or delete text for example
  • Merge and Split External or Newly Created PDF Documents - You can merge external or newly created PDF documents. Merge means to take all or a part of the PDF pages from one document and to add them to another document. Split means to take a range of pages from a document and add them to a new PDF document
  • Extract the Text from PDF Documents - HiQPdf Library allows you to extract the text from PDF documents to .NET String objects. When you extract the text you can choose the extraction mode and the range of PDF pages from where to extract the text.
  • Search Text in PDF Documents - HiQPdf Library allows you to search a text in a PDF document. The search can match the case or whole word only and you can choose the range of PDF pages where to search the text. The library returns the positions and the bounds of the text instances in PDF document pages.
  • Extract the Images from PDF Documents - HiQPdf Library allows you to extract the images from PDF documents to memory objects or to image files in a folder. You can choose the range of PDF pages from where to extract the images.
  • Rasterize PDF Pages to Images - HiQPdf Library allows you to rasterize PDF pages to image objects in memory or to image files in a folder. You can choose the color space of resulted images, the resolution of the rasterization and the range of PDF pages to rasterize.

HTML to PDF Converter for .NET - C# Code Sample for ASP.NET

protected void buttonConvertToPdf_Click(object sender, EventArgs e)
    // create the HTML to PDF converter
    HtmlToPdf htmlToPdfConverter = new HtmlToPdf();

    // set browser width
    htmlToPdfConverter.BrowserWidth = int.Parse(textBoxBrowserWidth.Text);

    // set browser height if specified, otherwise use the default
    if (textBoxBrowserHeight.Text.Length > 0)
        htmlToPdfConverter.BrowserHeight = int.Parse(textBoxBrowserHeight.Text);

    // set HTML Load timeout
    htmlToPdfConverter.HtmlLoadedTimeout = int.Parse(textBoxLoadHtmlTimeout.Text);

    // set PDF page size and orientation
    htmlToPdfConverter.Document.PageSize = GetSelectedPageSize();
    htmlToPdfConverter.Document.PageOrientation = GetSelectedPageOrientation();

    // set the PDF standard used by the document
    htmlToPdfConverter.Document.PdfStandard = checkBoxPdfA.Checked ? PdfStandard.PdfA : PdfStandard.Pdf;

    // set PDF page margins
    htmlToPdfConverter.Document.Margins = new PdfMargins(5);

    // set whether to embed the true type font in PDF
    htmlToPdfConverter.Document.FontEmbedding = checkBoxFontEmbedding.Checked;

    // set triggering mode; for WaitTime mode set the wait time before convert
    switch (dropDownListTriggeringMode.SelectedValue)
        case "Auto":
            htmlToPdfConverter.TriggerMode = ConversionTriggerMode.Auto;
        case "WaitTime":
            htmlToPdfConverter.TriggerMode = ConversionTriggerMode.WaitTime;
            htmlToPdfConverter.WaitBeforeConvert = int.Parse(textBoxWaitTime.Text);
        case "Manual":
            htmlToPdfConverter.TriggerMode = ConversionTriggerMode.Manual;
            htmlToPdfConverter.TriggerMode = ConversionTriggerMode.Auto;

    // set header and footer

    // set the document security
    htmlToPdfConverter.Document.Security.OpenPassword = textBoxOpenPassword.Text;
    htmlToPdfConverter.Document.Security.AllowPrinting = checkBoxAllowPrinting.Checked;

    // set the permissions password too if an open password was set
    if (htmlToPdfConverter.Document.Security.OpenPassword != null && htmlToPdfConverter.Document.Security.OpenPassword != String.Empty)
        htmlToPdfConverter.Document.Security.PermissionsPassword = htmlToPdfConverter.Document.Security.OpenPassword + "_admin";

    // convert HTML to PDF
    byte[] pdfBuffer = null;

    if (radioButtonConvertUrl.Checked)
        // convert URL to a PDF memory buffer
        string url = textBoxUrl.Text;

        pdfBuffer = htmlToPdfConverter.ConvertUrlToMemory(url);
        // convert HTML code
        string htmlCode = textBoxHtmlCode.Text;
        string baseUrl = textBoxBaseUrl.Text;

        // convert HTML code to a PDF memory buffer
        pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(htmlCode, baseUrl);

    // inform the browser about the binary data format
    HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");

    // let the browser know how to open the PDF document, attachment or inline, and the file name
    HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("{0}; filename=HtmlToPdf.pdf; size={1}",
        checkBoxOpenInline.Checked ? "inline" : "attachment", pdfBuffer.Length.ToString()));

    // write the PDF buffer to HTTP response

    // call End() method of HTTP response to stop ASP.NET page processing

private void SetHeader(PdfDocumentControl htmlToPdfDocument)
    // enable header display
    htmlToPdfDocument.Header.Enabled = checkBoxAddHeader.Checked;

    if (!htmlToPdfDocument.Header.Enabled)

    // set header height
    htmlToPdfDocument.Header.Height = 50;

    float pdfPageWidth = htmlToPdfDocument.PageOrientation == PdfPageOrientation.Portrait ?
                                htmlToPdfDocument.PageSize.Width : htmlToPdfDocument.PageSize.Height;

    float headerWidth = pdfPageWidth - htmlToPdfDocument.Margins.Left - htmlToPdfDocument.Margins.Right;
    float headerHeight = htmlToPdfDocument.Header.Height;

    // set header background color
    htmlToPdfDocument.Header.BackgroundColor = System.Drawing.Color.WhiteSmoke;

    string headerImageFile = Server.MapPath("~") + @"\DemoFiles\Images\HiQPdfLogo.png";
    PdfImage logoHeaderImage = new PdfImage(5, 5, 40, System.Drawing.Image.FromFile(headerImageFile));

    // layout HTML in header
    PdfHtml headerHtml = new PdfHtml(50, 5, @"<span style=""color:Navy; font-family:Times New Roman; font-style:italic"">
                    Quickly Create High Quality PDFs with </span><a href=""http://www.hiqpdf.com"">HiQPdf</a>", null);
    headerHtml.FitDestHeight = true;
    headerHtml.FontEmbedding = checkBoxFontEmbedding.Checked;

    // create a border for header

    PdfRectangle borderRectangle = new PdfRectangle(1, 1, headerWidth - 2, headerHeight - 2);
    borderRectangle.LineStyle.LineWidth = 0.5f;
    borderRectangle.ForeColor = System.Drawing.Color.Navy;

private void SetFooter(PdfDocumentControl htmlToPdfDocument)
    // enable footer display
    htmlToPdfDocument.Footer.Enabled = checkBoxAddFooter.Checked;

    if (!htmlToPdfDocument.Footer.Enabled)

    // set footer height
    htmlToPdfDocument.Footer.Height = 50;

    // set footer background color
    htmlToPdfDocument.Footer.BackgroundColor = System.Drawing.Color.WhiteSmoke;

    float pdfPageWidth = htmlToPdfDocument.PageOrientation == PdfPageOrientation.Portrait ?
                                htmlToPdfDocument.PageSize.Width : htmlToPdfDocument.PageSize.Height;

    float footerWidth = pdfPageWidth - htmlToPdfDocument.Margins.Left - htmlToPdfDocument.Margins.Right;
    float footerHeight = htmlToPdfDocument.Footer.Height;

    // layout HTML in footer
    PdfHtml footerHtml = new PdfHtml(5, 5, @"<span style=""color:Navy; font-family:Times New Roman; font-style:italic"">
                    Quickly Create High Quality PDFs with </span><a href=""http://www.hiqpdf.com"">HiQPdf</a>", null);
    footerHtml.FitDestHeight = true;
    footerHtml.FontEmbedding = checkBoxFontEmbedding.Checked;

    // add page numbering
    System.Drawing.Font pageNumberingFont = new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"),
                                8, System.Drawing.GraphicsUnit.Point);
    PdfText pageNumberingText = new PdfText(5, footerHeight - 12, "Page {CrtPage} of {PageCount}", pageNumberingFont);
    pageNumberingText.HorizontalAlign = PdfTextHAlign.Center;
    pageNumberingText.EmbedSystemFont = true;
    pageNumberingText.ForeColor = System.Drawing.Color.DarkGreen;

    string footerImageFile = Server.MapPath("~") + @"\DemoFiles\Images\HiQPdfLogo.png";
    PdfImage logoFooterImage = new PdfImage(footerWidth - 40 - 5, 5, 40, System.Drawing.Image.FromFile(footerImageFile));

    // create a border for footer
    PdfRectangle borderRectangle = new PdfRectangle(1, 1, footerWidth - 2, footerHeight - 2);
    borderRectangle.LineStyle.LineWidth = 0.5f;
    borderRectangle.ForeColor = System.Drawing.Color.DarkGreen;