Skip to content

Instantly share code, notes, and snippets.

@webgio
Last active September 7, 2016 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webgio/a95806209439b8cd319a32d9b24253f3 to your computer and use it in GitHub Desktop.
Save webgio/a95806209439b8cd319a32d9b24253f3 to your computer and use it in GitHub Desktop.
public static bool PdfContains(byte[] pdfcontent, string text)
{
using (var pdfReader = new PdfReader(pdfcontent))
{
for (int page = 1; page <= pdfReader.NumberOfPages; page++)
{
var strategy = new SimpleTextExtractionStrategy();
string currentText = PdfTextExtractor.GetTextFromPage(
pdfReader, page, strategy);
if (currentText.Contains(text))
return true
}
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment