【问题标题】:Extracting Tables from PDF document [duplicate]从 PDF 文档中提取表格 [重复]
【发布时间】:2014-08-20 16:14:35
【问题描述】:

我想以编程方式使用 C# 为大学项目提取 PDF 文档中的表格。我对itextsharp很熟悉。

  1. 有没有办法提取itextsharp 中的表格?

  2. 有没有其他免费的图书馆可以用于此目的?

  3. 我可以将PDF 转换为XML/HTML 以提取<table> 标记吗?如果可以,我可以使用免费库将PDF 转换为HTML 吗?

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

【问题讨论】:

  • 您查看过他们网站上的ITextSharp's 文档/示例吗?
  • 是的,到目前为止,我在 itextsharp 中找不到这样做的方法,因为表格主要是文本数据。我们无法区分表格数据和 itextsharp 中的文本数据。

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


【解决方案1】:

你能尝试这样的事情,并从我从 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;
}

【讨论】:

  • textextractionstrategy 用于从 pdf 文档中提取文本。是的,代码可以正常工作,但我需要提取表格。除了其他段落文本外,我如何识别表格内的文本?
猜你喜欢
  • 2011-01-18
  • 2021-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-02
  • 2014-05-02
  • 1970-01-01
相关资源
最近更新 更多