从PDF文档中提取表格

时间:2014-08-20 16:14:35

标签: c# pdf itextsharp pdf-to-html

我希望使用C#以大学项目的方式在PDF文档中提取表格。我对itextsharp非常熟悉。

  1. 有没有办法可以在itextsharp
  2. 中提取表格
  3. 我可以为此目的使用其他免费图书馆吗?
  4. 我可以将PDF转换为XML / HTML以提取<table>代码,如果有,我可以使用免费库进行PDF到HTML转换吗?

  5. 请给我一个合适的解决方案..

1 个答案:

答案 0 :(得分:0)

你能尝试这样的东西并从我从VB.Net转换为C#equiv的这个例子中扩展你需要的东西

public static string GetTextFromPDF(string PdfFileName)
{
    iTextSharp.text.pdf.PdfReader pdfReader = new iTextSharp.text.pdf.PdfReader(PdfFileName);
    dynamic sOut = string.Empty;

    for (i = 1; i <= pdfReader.NumberOfPages; i++) {
        iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
        sOut += iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(pdfReader, i, its);
    }
    return sOut;
}
相关问题