Get page count in a secured PDF
<p>I've created a C# application using below codings in order to get pdf page count.</p>

<pre><code>public static int GetNoOfPagesPDF(string FileName)
        {
            int result = 0;
            FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read);
            StreamReader r = new StreamReader(fs);
            string pdfText = r.ReadToEnd();

            System.Text.RegularExpressions.Regex regx = new Regex(@"/Type\s*/Page[^s]");
            System.Text.RegularExpressions.MatchCollection matches = regx.Matches(pdfText);
            result = matches.Count;
            return result;

        }
</code></pre>

<p>But I can't get the page count in a protected PDF. How can I get the page count in this kind of a situation.</p>
