I used regex to calculate the number of pages for pdf. Below is the code I used.
Regex regex = new Regex(@"/Type\s*/Page[^s]"); MatchCollection matches = regex.Matches(sr.ReadToEnd()); return matches.Count;
It works great with version below 1.6, but does not work with PDF files with version 1.6. It returns 0 pages if the pdf version is 1.6.
Mohammad shakir
source share