0

PDFファイルを読み、HTMLに変換する必要があります。現在、iTextsharp を使用して PDF を読んでいます。PDFファイルを読み取るための適切なドキュメントを備えたdllはありますか。

ありがとう

4

2 に答える 2

0

ITextSharpはかなりまともで、実装は非常に簡単です。これは、PDFを読み取り、テキストを文字列に入れて、Webフォームページのラベルに印刷する小さな例です。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;

namespace pdfreadertest
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            GetTextFromPDFFile(@"c:\example.pdf", 1);
        }

        public void GetTextFromPDFFile(string pdfFile, int pageNumber)
        {
            // Call the reader to read the pdf file
            PdfReader pdfReader = new PdfReader(pdfFile);

            // Extract the text from the pdf reader and put into a string
            string pdfText = PdfTextExtractor.GetTextFromPage(pdfReader, pageNumber);

            // Try and close the reader
            try
            {
                pdfReader.Close();
            }
            catch{ }

            // Put the string (pdf text) into a label to display on page
            this.lblPdfText.Text = pdfText;
        }
    }
}

お役に立てば幸いです。

于 2012-07-13T11:06:00.783 に答える
-1

iText.Net、PDF Sharp、Sharp PDFなどのGoogleのような他のいくつかのライブラリがありますが、iTextSharpは最も人気のあるものの1つだと思いますが、それらはたくさんあります。私はiTextSharpを使用しましたが、気に入っています。

于 2012-07-13T10:51:29.500 に答える