Get number of pages in a PDF file


/ Published in: C#
Save to your folder(s)

Open a PDF document and store the data in a string. Provide that string to this function and it will return the number of pages in the PDF.


Copy this code and paste it in your HTML
  1. public static int GetNumberOfPages(string pdfData)
  2. {
  3. var regx = new Regex(@"/Type\s*/Page[^s]");
  4. var matches = regx.Matches(pdfData);
  5. return matches.Count;
  6. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.