B4J Code Snippet Windows only - Find a pdf printer

Discussion in 'B4J Code Snippets' started by Erel, Oct 2, 2019.

  1. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Sub FindPdfPrinter As ResumableSub
       
    Dim shl As Shell
       shl.Initialize(
    "shl""wmic"Array("printer""get""Name"))
       shl.Run(-
    1)
       
    Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
       
    If Success Then
           
    For Each line As String In Regex.Split("[\r\n]+", StdOut)
               
    If line.ToLowerCase.Contains("pdf"Then Return line.Trim
           
    Next
       
    End If
       
    Return ""
    End Sub
    Usage example:
    Code:
    Wait For (FindPdfPrinter) Complete (PdfPrinter As String)
    If PdfPrinter <> "" Then
    Depends on jShell library.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice