iTextsharp SimpleTextExtractionStrategy();

时间:2014-06-26 04:59:46

标签: c# pdf itextsharp

我正在使用ITextSharp遍历PDF文件。我找不到嵌入表格中的文字。

public bool ReadPdfFileSpecial(string fileName )
{

  var found = false;

  if (File.Exists(fileName))
  {
    PdfReader pdfReader = new PdfReader(fileName);

    for (int page = 1; page <= pdfReader.NumberOfPages; page++)
    {
      ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();

      string currentPageText = PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
      if (currentPageText.Contains("is over 18 years old. Children must be less than 19 years old to qualify for MediKids.  However, "))
        found = true; ;
    }
    pdfReader.Close();
  }
  return found;
}

0 个答案:

没有答案