title: Index was outside the bounds of the array while reading a .Pdf using iTextSharp
body: <p>Im using the Open Source Tool iTextSharp to read a .Pdf file in my Asp.Net MVC3 application which is coded in c#.Net.</p>
  
  <p>Below is my Code.</p>
  
  <pre><code>   filePath = Path.Combine(
                      AppDomain.CurrentDomain.BaseDirectory,
                      Path.GetFileName(Infile.FileName));
                      if (System.IO.File.Exists(filePath))
                      {
                          System.IO.File.Delete(filePath);
                      }
                      Infile.SaveAs(filePath);
                      var pdfdoc = new iTextSharp.text.Document();
                      PdfReader reader2 = new PdfReader((string)filePath);
                      string strText = string.Empty;
  
                      for (int page = 1; page &lt;= reader2.NumberOfPages; page++)
                      {
                          iTextSharp.text.pdf.parser.ITextExtractionStrategy its = new iTextSharp.text.pdf.parser.SimpleTextExtractionStrategy();
                          PdfReader reader = new PdfReader((string)filePath);
                          String s = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, page,its);
  
                          s = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(s)));
                          strText = strText + s;
                          reader.Close();
                      }
  </code></pre>
  
  <p>Im getting the Error on the line</p>
  
  <pre><code>  String s = iTextSharp.text.pdf.parser.PdfTextExtractor.GetTextFromPage(reader, page,its);
  </code></pre>
  
  <p>The error is <strong>Index was outside the bounds of the array.</strong><br>
  Regards.</p>