// THIS IS STRING BY USING WHICH I AM EXTRACTING ALL TEXT FROM PDF FILE
string t = ExtractAlTextFromPdf(inputFile);
...
public static string ExtractAlTextFromPdf(string inputFile)
{
//Sanity checks
if (string.IsNullOrEmpty(inputFile))
throw new ArgumentNullException("inputFile");
if (!System.IO.File.Exists(inputFile))
throw new System.IO.FileNotFoundException("Cannot find inputFile", inputFile);
//Create a stream reader (not necessary but I like to control locks and permissions)
using (FileStream SR = new FileStream(inputFile, FileMode.Open, FileAccess.Read, FileShare.Read))
{
//Create a reader to read the PDF
iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(SR);
//Create a buffer to store text
StringBuilder text = new StringBuilder();
//Use the PdfTextExtractor to get all of the text on a page-by-page basis
for (int i = 1; i <= reader.NumberOfPages; i++)
{
text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
}
return text.ToString();
}
}
// when i pass this string to method
public string stem(string word)
{
if (word.Length < 3) return word;
StringBuilder sb = new StringBuilder(word.ToLower());
if (sb[0] == '\'') sb.Remove(0, 1);
for (int i = 0; i < exceptions.Length / 2; ++i)
if (word == exceptions[i, 0])
return exceptions[i, 1];
int r1 = 0, r2 = 0;
changeY(sb);
computeR1R2(sb, ref r1, ref r2);
step0(sb);
step1a(sb);
for (int i = 0; i < exceptions2.Length; ++i)
if (sb.ToString() == exceptions2[i])
return exceptions2[i];
step1b(sb, r1);
step1c(sb);
step2(sb, r1);
step3(sb, r1, r2);
step4(sb, r2);
step5(sb, r1, r2);
return sb.ToString().ToLower();
}
它给出了错误