title: Search particular word in PDF using iTextSharp
body: <p>I have a PDF file in my System drive. I want to write a program in C# using iTextSharp to search for a particular word in that PDF.</p>
  <p>Say I want to search &quot;StackOverFlow&quot;: If the PDF contains the Word &quot;StackOverFlow&quot;, it should return true, else it should return false.</p>
  <p>What I have tried till now is:</p>
  <pre><code>public string ReadPdfFile(string fileName)
  {
      StringBuilder text = new StringBuilder();
  
      if (File.Exists(fileName))
      {
          PdfReader pdfReader = new PdfReader(fileName);
  
          for (int page = 1; page &lt;= pdfReader.NumberOfPages; page++)
          {
              ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
              string currentText = &quot;2154/MUM/2012 A&quot;;// PdfTextExtractor.GetTextFromPage(pdfReader, page, strategy);
  
              currentText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText)));
              text.Append(currentText);
          }
          pdfReader.Close();
      }
      return text.ToString();
  }
  </code></pre>