Question

The problem seen to appear again in printing job...

I have a printer(Epson TM-T88IV Receipt). Before printing, i would like to check if printer is available for printing or not (connect or not). if not, i will show the print preview form. otherwise it will print automatically

any solution in vb.net code

Thanks in advance
Makara

Was it helpful?

Solution

I'm not 100% sure this will work so try it first:

'usage
For Each prn As String In PrinterSettings.InstalledPrinters
    Debug.WriteLine(String.Format("Is printer {0} online? {1}", prn, CheckPrinter(prn).ToString))
Next

'function to test printer status
Private Function CheckPrinter(ByVal printerName As String) As Boolean
    Try
        Dim printDocument As PrintDocument = New PrintDocument
        printDocument.PrinterSettings.PrinterName = printerName
        Return printDocument.PrinterSettings.IsValid
    Catch ex As System.Exception
        Return False
    End Try
End Function

OTHER TIPS

As you use Vb.net I guess you are on a windows machine. Use your operating systems API. Like e.g. GetPrinterStatus.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top