Skip to content

Bukk94/PrintServiceLibrary

Repository files navigation

Print service library (PSL)

MIT License version Build Status

This library serves as an interface into a printer's communication. The user can communicate with various connection interfaces using a single API interface.

API can communicate using:

  • USB port
  • LPT (Parallel port)
  • COM (Serial port)
  • Network connection (TCP/IP)

PSL was mainly developed for Zebra printers using the ZPL language. But basic communication interface should work with any kind of printer and language as long as you follow standard printer's structure and language.

ZPL dependant methods

These methods are only for printers that support the ZPL language.

  • UploadFontToPrinter
  • ListPrinterMemory
  • GetPrinterFreeMemory
  • PreviewZPLPrint

Code Examples

Printing using the USB port

string zplCommands = "^XA^FO100,153^FDTest Text to Print^FS^XZ";
IPrintService printService = new PrintService();

// Sends zplCommands to printer called "my printer" 
// using the USB port. Printer will print 5 copies.
printService.PrintUSB(zplCommands, "my printer", 5);

Printing using TCP/IP

string zplCommands = "^XA^FO100,153^FDTest Text to Print^FS^XZ";
IPrintService printService = new PrintService();

// Sends zplCommands to printer on IP 192.168.1.1:9100
printService.PrintNetwork(zplCommands, System.Net.IPAddress.Parse("192.168.1.1"), 9100);

Getting list of local printers

IPrintService printService = new PrintService();

// Loads all locally installed printers and return list of their names
printService.LoadInstalledPrinters();

Neodynamic integration

PSL API has Neodynamic ThermalLabel SDK integration. If you do have Neodynamic license key, you can pass it in PrintService constructor and call methods like PreviewZPLPrint.

These methods further enhance Neodynamic ZPL code generation from raw XML template by locally previewing ZPL commands that will get sent to the printer or by local data binding without needing communication with the printer.

You can use these commands regardless of Neodynamic SDK license but beware that the "TRIAL" logo will be embedded in the ZPL commands.

Lightweight version

There is also a Lightweight version in a separate branch that doesn't contain Neodynamic ThermalLabel SDK. This removes all necessary libraries (which are quite large) and only provides printer communication.

Languages

PSL API is multilingual. Supported languages are English and Czech.

Licensing

PSL API is licensed under the MIT license (more in LICENSE.MD).