Click here to Skip to main content
15,896,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to convert pdf file to html using asp.net
Posted

Check this similar CP discussion

PDF to HTML conversion in asp.net(c#)[^]
 
Share this answer
 
XML
using System;
using <span data-scayt_word="Bytescout.PDF2HTML" data-scaytid="92">Bytescout.PDF2HTML</span>;

<span data-scayt_word="namespace" data-scaytid="93">namespace</span> <span data-scayt_word="ExtractHTML" data-scaytid="94">ExtractHTML</span>
{
    public partial class _Default : <span data-scayt_word="System.Web.UI.Page" data-scaytid="95">System.Web.UI.Page</span>
    {
        protected void Page_Load(object sender, <span data-scayt_word="EventArgs" data-scaytid="96">EventArgs</span> e)
        {
            // This test file will be copied to the project directory on the pre-build event (see the project properties).
            String <span data-scayt_word="inputFile" data-scaytid="97">inputFile</span> = <span data-scayt_word="Server.MapPath" data-scaytid="98">Server.MapPath</span>("<span data-scayt_word="sample2.pdf" data-scaytid="99">sample2.pdf</span>");

            // Create <span data-scayt_word="Bytescout.PDF2HTML.HTMLExtractor" data-scaytid="100">Bytescout.PDF2HTML.HTMLExtractor</span> instance
            <span data-scayt_word="HTMLExtractor" data-scaytid="101">HTMLExtractor</span> extractor = new <span data-scayt_word="HTMLExtractor" data-scaytid="102">HTMLExtractor</span>();
            <span data-scayt_word="extractor.RegistrationName" data-scaytid="103">extractor.RegistrationName</span> = "demo";
            <span data-scayt_word="extractor.RegistrationKey" data-scaytid="104">extractor.RegistrationKey</span> = "demo";

            // Set HTML with CSS extraction mode
            <span data-scayt_word="extractor.ExtractionMode" data-scaytid="105">extractor.ExtractionMode</span> = <span data-scayt_word="HTMLExtractionMode.HTMLWithCSS" data-scaytid="106">HTMLExtractionMode.HTMLWithCSS</span>;

            // Load sample PDF document
            <span data-scayt_word="extractor.LoadDocumentFromFile" data-scaytid="107">extractor.LoadDocumentFromFile</span>(<span data-scayt_word="inputFile" data-scaytid="108">inputFile</span>);

            <span data-scayt_word="Response.Clear" data-scaytid="109">Response.Clear</span>();
            <span data-scayt_word="Response.ContentType" data-scaytid="110">Response.ContentType</span> = "text/html";

            // Save extracted text to output stream
            <span data-scayt_word="extractor.SaveHtmlToStream" data-scaytid="111">extractor.SaveHtmlToStream</span>(<span data-scayt_word="Response.OutputStream" data-scaytid="112">Response.OutputStream</span>);

            <span data-scayt_word="Response.End" data-scaytid="113">Response.End</span>();

            <span data-scayt_word="extractor.Dispose" data-scaytid="114">extractor.Dispose</span>();
        }
    }
}



check this
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900