Thursday, 8 May 2014

Get Page No. in Pdf file using VB.NET

 Get Page No. in Pdf file using VB.NET :
Public Function getNumberOfPdfPages(fileName As String) As Integer
        Using sr As New StreamReader(File.OpenRead(fileName))
            Dim regex As New Regex("/Type\s*/Page[^s]")
            Dim matches As MatchCollection = regex.Matches(sr.ReadToEnd())

            Return matches.Count
        End Using
    End Function