Link Search Menu Expand Document

Getting Started in ASP.NET

The following sample demonstrates how to convert PDF document to HTML in ASP.NET using Bytescout PDF To HTML SDK

C#
<legacyBold xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Default.aspx:</legacyBold>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ExtractHTML._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>

        <legacyBold xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">Default.aspx.cs:</legacyBold>
using System;
using Bytescout.PDF2HTML;

namespace ExtractHTML
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // This test file will be copied to the project directory on the pre-build event (see the project properties).
            String inputFile = Server.MapPath("sample2.pdf");

            // Create Bytescout.PDF2HTML.HTMLExtractor instance
            HTMLExtractor extractor = new HTMLExtractor();
            extractor.RegistrationName = "demo";
            extractor.RegistrationKey = "demo";

            // Set HTML with CSS extraction mode
            extractor.ExtractionMode = HTMLExtractionMode.HTMLWithCSS;

            // Load sample PDF document
            extractor.LoadDocumentFromFile(inputFile);

            Response.Clear();
            Response.ContentType = "text/html";

            // Save extracted text to output stream
            extractor.SaveHtmlToStream(Response.OutputStream);

            Response.End();

            extractor.Dispose();
        }
    }
}