Hi, I am having a task for counting the number of pages in a PDF file, here is my code.
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); StreamReader r = new StreamReader(fs); string pdfText = r.ReadToEnd(); Regex rxl = new Regex(@"/Type\s/Page[^s]"); MatchCollection match = rxl.Matches(pdfText); return match.Count.ToString();
But its not returning the page count for all the pdf files. Can anyone share me a code which will count all the pages for a PDF file. Regards, Dharma
Regards, Dharma Editor,Mentor,MVM Try and fail but don't fail and try Me and DNS
|
| Author: Ankush 29 Oct 2008 | Member Level: Silver | Rating: Points: 1 |
I think we can use Regex as "/Type\s*/Page[^s]".This can help you.
|