Count total number of page in PDF file in C# .NET 2.0?
Author: Zunnair
Download Source Code : 726_PdfPageCount.zip
In this simple article you will learn that how you can count total number of pages in PDF File.
Simply just create New Project of windows application in C#.
Import some APIs
using System.IO;
using System.Text.RegularExpressions;
Drag one label, two buttons, one fileOpenDialog object and one textbox on the form.
Now write following code on form Load event
Now write code on buttons events
Now this is the function which count pages of PDF
In this funciton we are opening PDF file. and then using aDoc. Regex(@"/Type\s*/Page[^s]"); function we count total pages of PDF file.
This is the simple page counting source.