محاسبه تعداد صفحات یک فایل PDF توسط عبارات منظم :
[CSHARP]
using System.IO;
using System.Text.RegularExpressions;

int PDF_page_counter(string path)
{
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string pdf_text = sr.ReadToEnd();
//======================================
Regex rgx = new Regex(@"/Type\s*/Page[^s]");
MatchCollection matches = rgx.Matches(pdf_text);
return matches.Count;
}

[/CSHARP]

استفاده
[CSHARP]MessageBox.Show(PDF_page_counter(@"E:\1.pdf").ToSt ring());[/CSHARP]