2012-07-13 85 views
-1

我需要閱讀PDF文件,並需要轉換爲HTML。目前我正在使用iTextsharp來閱讀PDF。有沒有適當的文件的dll 閱讀pdf文件在C#中閱讀PDF文本圖像

感謝

+0

檢查這個http://stackoverflow.com/questions/2295555/how-to-convert-pdf-into-html-using-c-sharp – Matt 2012-07-13 10:53:45

回答

-2

我覺得iTextSharp的是最流行的一個,即使有其他幾個庫像 iText.Net,PDF夏普,夏普等PDF谷歌 它,你會發現他們中的很多。我已經使用iTextSharp,我喜歡它。

+0

OP說他已經使用iTextsharp,所以你可以詳細說明一下你的答案是關於? – yms 2012-07-24 14:34:16

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; 
     } 
    } 
} 

希望有所幫助。

+0

如何使用iTextsharp讀取圖像? – Sam 2012-07-13 11:45:07