Print Jobs
PrintJob, WindowsPrintJob & WebPrintJob
Note
For sample code about using PrintJob, WindowsPrintJob and WebPrintJob classes, please refer to ThermalLabel sample projects
PrintJob
The PrintJob is the object that specifies information about how the ThermalLabel object is generated in raw printer commands, including settings like label orientation and number of copies. It is also used for exporting or saving a ThermalLabel object to raster image formats or Adobe PDF documents which is very useful when you are in development/test phase or have no access to a physical thermal printer.
WindowsPrintJob
The WindowsPrintJob (which is found in the Neodynamic.SDK.ThermalLabel.WindowsPrinting.dll) is the object that specifies information about how the ThermalLabel object is printed, including the printer device settings and communication, label orientation, number of copies, etc. in a Windows client app project.
WebPrintJob
The WebPrintJob (which is found in the Neodynamic.SDK.ThermalLabel.WebPrinting.dll) is the object that specifies information about how the ThermalLabel object is printed, including the printer device settings and communication, label orientation, number of copies, etc. in an ASP.NET project.
Printer Utilities
ThermalLabel SDK does not only provide thermal label designing and printing but a set of commands for Zebra and Honeywell/Intermec Thermal Printers administration too. ThermalLabel SDK features the PrintUtils object which is used for printing jobs that are not directly related to label printing like printer's memory devices administration. Please refer to PrintUtils class reference for more details. PrinUtils class is available in the Neodynamic.SDK.ThermalLabel.WindowsPrinting.dll assembly.
Thermal Printer Communication
Thermal Printers can be connected by Serial Port (RS-232), Parallel Port (Centronics), USB and IP Ethernet network depending on the printer model. Printer communication with ThermalLabel SDK is handled by using PrinterCommunication class. However, that class is not directly used in .NET code but through a WindowsPrintJob object or the PrintUtils class which are found in the Neodynamic.SDK.ThermalLabel.WindowsPrinting.dll assembly.
USB
If your printer is connected by USB, then you will have to install/configure a Windows Driver for the printer which can be the Zebra Universal Driver (ZUD) or the Windows built-in "Microsoft Generic Text Only" printer driver before trying to use it with ThermalLabel SDK. The following code is about how to configure printer communication for a printer connected by USB through a WindowsPrintJob object:
Note
These same settings are valid for the PrinterDriver option.
VB
'Create a WindowsPrintJob object
Dim pj As New WindowsPrintJob()
pj.PrinterSettings = New PrinterSettings()
'Thermal Printer is connected through USB
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB
'Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203
'Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
'Set Thermal Printer name
pj.PrinterSettings.PrinterName = "Zebra TLP2844-Z"
CS
//Create a WindowsPrintJob object
WindowsPrintJob pj = new WindowsPrintJob();
pj.PrinterSettings = new PrinterSettings();
//Thermal Printer is connected through USB
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.USB;
//Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203;
//Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
//Set Thermal Printer name
pj.PrinterSettings.PrinterName = "Zebra TLP2844-Z";
Parallel Port (Centronics)
If your printer is connected by Parallel Port (Centronic), then you just need to know the parallel port name to specify it in the PrinterCommunication object. The following code is about how to configure printer communication for a printer connected by LPT1 Parallel Port through a WindowsPrintJob object:
VB
'Create a WindowsPrintJob object
Dim pj As New WindowsPrintJob()
pj.PrinterSettings = New PrinterSettings()
'Thermal Printer is connected through Parallel Port
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Parallel
'Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203
'Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
'Set Thermal Printer parallel port name
pj.PrinterSettings.ParallelPortName= "LPT1"
CS
//Create a WindowsPrintJob object
WindowsPrintJob pj = new WindowsPrintJob();
pj.PrinterSettings = new PrinterSettings();
//Thermal Printer is connected through Parallel Port
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Parallel;
//Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203;
//Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
//Set Thermal Printer parallel port name
pj.PrinterSettings.ParallelPortName= "LPT1";
Serial Port (RS-232)
If your printer is connected by Serial Port (RS-232), then you need to know the Thermal Printer serial port settings to specify it in the PrinterCommunication object. Please refer to your Printer User Manual and look for the Serial Communication parameters. The following code is about how to configure printer communication for a Zebra printer connected by COM1 Serial Port through a WindowsPrintJob object:
VB
'Create a WindowsPrintJob object
Dim pj As New WindowsPrintJob()
pj.PrinterSettings = New PrinterSettings()
'Thermal Printer is connected through Serial Port
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Serial
'Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203
'Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
'Set Thermal Printer serial port settings
pj.PrinterSettings.Communication.SerialPortName = "COM1"
pj.PrinterSettings.Communication.SerialPortBaudRate = 9600
pj.PrinterSettings.Communication.SerialPortDataBits = 8
pj.PrinterSettings.Communication.SerialPortStopBits = SerialPortStopBits.One
pj.PrinterSettings.Communication.SerialPortParity = SerialPortParity.None
pj.PrinterSettings.Communication.SerialPortFlowControl = SerialPortHandshake.XOnXOff
CS
//Create a WindowsPrintJob object
WindowsPrintJob pj = new WindowsPrintJob();
pj.PrinterSettings = new PrinterSettings();
//Thermal Printer is connected through Serial Port
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Serial;
//Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203;
//Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
//Set Thermal Printer serial port settings
pj.PrinterSettings.Communication.SerialPortName = "COM1";
pj.PrinterSettings.Communication.SerialPortBaudRate = 9600;
pj.PrinterSettings.Communication.SerialPortDataBits = 8;
pj.PrinterSettings.Communication.SerialPortStopBits = SerialPortStopBits.One;
pj.PrinterSettings.Communication.SerialPortParity = SerialPortParity.None;
pj.PrinterSettings.Communication.SerialPortFlowControl = SerialPortHandshake.XOnXOff;
IP Ethernet Network
If your printer is connected by an IP Ethernet network, then you just need to know the IP Address as well as the port number for the printer to specify them in the PrinterCommunication object. The following code is about how to configure printer communication for a printer connected by IP Ethernet through a WindowsPrintJob object:
VB
'Create a WindowsPrintJob object
Dim pj As New WindowsPrintJob()
pj.PrinterSettings = New PrinterSettings()
'Thermal Printer is connected through IP network
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Network
'Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203
'Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
'Set Thermal Printer network info
pj.PrinterSettings.Communication.NetworkIPAddress = System.Net.IPAddress.Parse("127.0.0.1")
pj.PrinterSettings.Communication.NetworkPort = 9100
CS
//Create a WindowsPrintJob object
WindowsPrintJob pj = new WindowsPrintJob();
pj.PrinterSettings = new PrinterSettings();
//Thermal Printer is connected through IP network
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Network;
//Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203;
//Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
//Set Thermal Printer network info
pj.PrinterSettings.Communication.NetworkIPAddress = System.Net.IPAddress.Parse("127.0.0.1");
pj.PrinterSettings.Communication.NetworkPort = 9100;
- In case you do not know which is the IP Address of the printer but the Host name, then you can use the following code instead:
VB
'Create a WindowsPrintJob object
Dim pj As New WindowsPrintJob()
pj.PrinterSettings = New PrinterSettings()
'Thermal Printer is connected through IP network
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Network
'Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203
'Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL
'Set Thermal Printer network info
pj.PrinterSettings.PrinterName = "PRINTER HOST NAME"
pj.PrinterSettings.Communication.NetworkPort = 9100
CS
//Create a WindowsPrintJob object
WindowsPrintJob pj = new WindowsPrintJob();
pj.PrinterSettings = new PrinterSettings();
//Thermal Printer is connected through IP network
pj.PrinterSettings.Communication.CommunicationType = CommunicationType.Network;
//Set Thermal Printer resolution
pj.PrinterSettings.Dpi = 203;
//Set Thermal Printer language
pj.PrinterSettings.ProgrammingLanguage = ProgrammingLanguage.ZPL;
//Set Thermal Printer network info
pj.PrinterSettings.PrinterName = "PRINTER HOST NAME";
pj.PrinterSettings.Communication.NetworkPort = 9100;