2012-07-13 88 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