如何使用asp.net将pdf文件转换为html [英] how to convert pdf file to html using asp.net

查看:94
本文介绍了如何使用asp.net将pdf文件转换为html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用asp.net将pdf文件转换为html

how to convert pdf file to html using asp.net

推荐答案

查看类似的CP讨论



asp.net中的PDF到HTML转换(c#) [ ^ ]
Check this similar CP discussion

PDF to HTML conversion in asp.net(c#)[^]


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


使用iTextSharp Dll



将PDF转换为HTML

阅读PDF文档
Use iTextSharp Dll

Convert PDF to HTML
Read PDF document


这篇关于如何使用asp.net将pdf文件转换为html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆