Establishes a USB connection to a printer

Namespace:  ZSDK_API.Comm
Assembly:  ZSDK_API (in ZSDK_API.dll) Version: 1.1.123.0

Syntax

C#
public class UsbPrinterConnection : ZebraPrinterConnectionA
Visual Basic (Declaration)
Public Class UsbPrinterConnection _
	Inherits ZebraPrinterConnectionA

Remarks

The ZebraLink Multiplatform SDK supports printing from Windows CE devices via a USB connection to ZPL-based Tabletop, Desktop and Kiosk printers

Examples

Establishes a USB connection to a printer
CopyC#
using System;
using ZSDK_API.Comm;
using System.Text;
using ZSDK_API.ApiException;

public void SendZplOverUsb() {

    try {
        // Instantiate connection for ZPL USB port with a given port name. 
        ZebraPrinterConnection thePrinterConn = new UsbPrinterConnection("LPT1:"); // "LPT" is the default prefix for most Windows CE/Mobile USB ports 

        // Open the connection - physical connection is established here.
        thePrinterConn.Open();

        // This example prints "This is a ZPL test." near the top of the label.
        String zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

        // Send the data to printer as a byte array.
        thePrinterConn.Write(Encoding.Default.GetBytes(zplData));

        // Close the connection to release resources.
        thePrinterConn.Close();

    } catch (ZebraPrinterConnectionException e) {

        // Handle communications error here.
        Console.Write(e.StackTrace);
    }
}
CopyVB.NET
Imports ZSDK_API.Comm
Imports System.Text
Imports ZSDK_API.ApiException
Imports System.Threading
Public Sub SendZplOverUsb()

  Try
   ' Instantiate connection for ZPL USB port with a given port name. 
   Dim thePrinterConn As ZebraPrinterConnection = New UsbPrinterConnection("LPT1:") ' "LPT" is the default prefix for most Windows CE/Mobile USB ports


   ' Open the connection - physical connection is established here.
   thePrinterConn.Open()

   ' This example prints "This is a ZPL test." near the top of the label.
   Dim zplData As [String] = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ"

   ' Send the data to printer as a byte array.
   thePrinterConn.Write(Encoding.[Default].GetBytes(zplData))

   ' Close the connection to release resources.


   thePrinterConn.Close()
  Catch e As ZebraPrinterConnectionException

   ' Handle communications error here.
   Console.Write(e.StackTrace)
 End Try
End Sub

Inheritance Hierarchy

System..::.Object
  ZSDK_API.Comm..::.ZebraPrinterConnectionA
    ZSDK_API.Comm..::.UsbPrinterConnection

See Also