Posted By

poxet on 11/10/10



Versions (?)

Get number of pages in a PDF file

 / Published in: C#

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.

  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  

You need to login to post a comment.