Skip Navigation Links.
In this demo you can learn how to convert the pages of a PDF document to HTML documents. You can choose the resolution of the resulted HTML document, the zoom level and the range of PDF pages to convert to HTML.
Server Settings
IP: Port: Password:
PDF document:
Open the Input PDF Document
Resolution: DPI Zoom: %
Page Range
From: To:
Skip Navigation Links
C# Code
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

using HiQPdfClient;

namespace HiQPdf_Demo
    public partial class PdfToHtmlConverter : System.Web.UI.Page
        protected void buttonConvertPdfToHtml_Click(object sender, EventArgs e)
            string serverIP = textBoxServerIP.Text;
            uint serverPort = uint.Parse(textBoxServerPort.Text);
            string serverPassword = textBoxServerPassword.Text;

            // get the PDF file
            string pdfFile = Server.MapPath("~") + @"\DemoFiles\Pdf\Presentation.pdf";

            // create the PDF to HTML converter
            PdfToHtml pdfToHtmlConverter = new PdfToHtml(serverIP, serverPort);

            // use server password if necessary
            if (serverPassword.Length > 0)
                pdfToHtmlConverter.ServerPassword = serverPassword;

            // set a demo serial number
            pdfToHtmlConverter.SerialNumber = "YCgJMTAE-BiwJAhIB-EhlWTlBA-UEBRQFBA-U1FOUVJO-WVlZWQ==";

            // set the conversion resolution in DPI
            pdfToHtmlConverter.DPI = int.Parse(textBoxDPI.Text);

            // set the zoom level
            pdfToHtmlConverter.Zoom = int.Parse(textBoxZoom.Text);

            int fromPdfPageNumber = int.Parse(textBoxFromPage.Text);
            int toPdfPageNumber = textBoxToPage.Text.Length > 0 ? int.Parse(textBoxToPage.Text) : 0;

            // convert a range of pages of the PDF document to HTML documents in memory
            // the HTML can also be produced to a folder using the ConvertToHtmlFiles method
            // or they can be produced one by one using the RaisePageConvertedToHtmlEvent method
            PdfPageHtmlCode[] htmlDocuments = pdfToHtmlConverter.ConvertToHtml(pdfFile, fromPdfPageNumber, toPdfPageNumber);

            // return if no page was converted
            if (htmlDocuments.Length == 0)

            // get the first page HTML bytes in a buffer
            byte[] htmlDocumentBuffer = null;
                // get the HTML document UTF-8 bytes
                htmlDocumentBuffer = Encoding.UTF8.GetBytes(htmlDocuments[0].HtmlCode);
                // dispose the HTML documents
                for (int i = 0; i < htmlDocuments.Length; i++)

            // inform the browser about the binary data format
            HttpContext.Current.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");

            // let the browser know how to open the HTML document and the HTML document name
                String.Format("attachment; filename=Page.html; size={0}", htmlDocumentBuffer.Length.ToString()));

            // write the HTML document buffer to HTTP response

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

        protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                string pageUri = HttpContext.Current.Request.Url.AbsoluteUri;
                hyperLinkOpenPdf.NavigateUrl = pageUri.Substring(0, pageUri.LastIndexOf('/')) + @"/DemoFiles/Pdf/Presentation.pdf";