pdfinfo to get Page Count

    Function GetPageCount(sFile As String) As Integer

        Dim myprocess As New Process



        'Program you want to launch execute etc.

        'myprocess.StartInfo.FileName = "c:\windows\system32\openfiles.exe"

        myprocess.StartInfo.FileName = "pdfinfo.exe"

        myprocess.StartInfo.Arguments = Chr(34) & sFile & Chr(34) '& " " & "|C:\Windows\System32\grep.exe -i " & Chr(34) & "Pages: " & Chr(34)

        'myprocess.StartInfo.WorkingDirectory = sTEMPpath

        'myprocess.StartInfo.UserName = "xsvcacct"

        'myprocess.StartInfo.Password = LoadSecureString("RunM3n0w")

        'myprocess.StartInfo.Domain = "CHNET"

        'This is important.  Since this is a windows service it will run

        'even though no one is logged in.

        'Therefore there is not desktop available so you better

        'not show any windows dialogs

        myprocess.StartInfo.UseShellExecute = False

        myprocess.StartInfo.CreateNoWindow = True

        ''We want to redirect the output from the openfiles call to the program

        ''Since there won't be any window to display it in

        myprocess.StartInfo.RedirectStandardOutput = True

        'myprocess.StartInfo.RedirectStandardInput = True

        myprocess.StartInfo.RedirectStandardError = True

        myprocess.StartInfo.StandardOutputEncoding = Text.Encoding.ASCII

        'myprocess.StartInfo.RedirectStandardOutput = False

        Debug.Print(myprocess.StartInfo.FileName & " " & myprocess.StartInfo.Arguments)


        Dim sErrText As String = myprocess.StandardError.ReadToEnd()


        If Len(sErrText) > 0 Then

            Return -1


            Dim sPages As String = myprocess.StandardOutput.ReadToEnd()

            Debug.Print("grab : " & funGrabBetween(sPages, "Pages:", vbCrLf))

            Return Val(funGrabBetween(sPages, "Pages:", vbCrLf))

        End If

        'Dim sOutput As String

        'Using oStreamReader As System.IO.StreamReader = myprocess.StandardOutput

        '    sOutput = oStreamReader.ReadToEnd()

        'End Using

    End Function


Count Characters Function

    Public Function CountCharacter(ByVal value As String, ByVal ch As Char) As Integer

        Return value.Count(Function(c As Char) c = ch)

    End Function