Hello,
I have to count the number of pages in the document that I am uploading. This document can be a word file, xls, txt or pdf. I have my code working for pdf but not for other types. Here is the code that works for pdf- it uses regex
please help me with this. I am totally stuck.
I have to count the number of pages in the document that I am uploading. This document can be a word file, xls, txt or pdf. I have my code working for pdf but not for other types. Here is the code that works for pdf- it uses regex
Code:
System.IO.FileStream fs = new System.IO.FileStream(filepath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.StreamReader r = new System.IO.StreamReader(fs);
string text = r.ReadToEnd();
System.Text.RegularExpressions.Regex regx = new System.Text.RegularExpressions.Regex(@"/Type\s*/Page[^s]");
System.Text.RegularExpressions.MatchCollection matches = regx.Matches(text);
noOfPages = matches.Count;
please help me with this. I am totally stuck.