Skip to content
/ zsdk Public
forked from luis901101/zsdk

Adds bluetooth printing to luis901101/zsdk

License

Notifications You must be signed in to change notification settings

KanbanBOX/zsdk

 
 

Repository files navigation

zsdk

Zebra Link OS SDK Flutter plugin.

This is a flutter plugin for the Link-OS Multiplatform SDK for Zebra

Features

Feature iOS Android
Print ZPL from String over TCP/IP
Print ZPL from file over TCP/IP
Print PDF from byte array over TCP/IP ☑️ ☑️
Print PDF from file over TCP/IP
Get printer settings over TCP/IP
Set printer settings over TCP/IP
Check printer status over TCP/IP
Print configuration label over TCP/IP
Run calibration over TCP/IP
Reboot printer over TCP/IP
Print ZPL from String over Bluetooth ☑️
Print ZPL from file over Bluetooth ☑️
Print PDF from byte array over Bluetooth ☑️ ☑️
Print PDF from file over Bluetooth ☑️
Get printer settings over Bluetooth ☑️
Set printer settings over Bluetooth ☑️
Check printer status over Bluetooth ☑️
Print configuration label over Bluetooth ☑️
Run calibration over Bluetooth ☑️
Reboot printer over Bluetooth ☑️
Find printers over Bluetooth ☑️

Note:

Since v3.1.0+1 the plugin supports PDF direct printing on both iOS and Android, before this version, the PDF printing was only available on Android, and it was by using some kind of workaround converting the PDF to image and printing it as image, which was not reliable and caused some issues depending on the document dimensions, etc. Now the PDF Direct printing is the right way and according to the manufacturer, you just need to be sure your printing OS is >= Link-OS v6.3 and you have installed the Virtual Device for PDF Direct.

Steps:

  1. Upgrade Zebra Printer Firmware
  2. Install and Enable Virtual Device for PDF Direct

iOS Setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

Android Setup

No setup required

How to use

Add dependency

# Add this line to your flutter project dependencies
zsdk: ^2.0.0+11

and run flutter pub get to download the library sources to your pub-cache.

Initialize a ZSDK object

final zsdk = ZSDK();
// or if you'd like to use the bluetooth printing
final zsdk = ZSDK(printerFound: (PrinterConnectionData printer) {
  // Do something here when a printer is found
});

Start the printer calibration

zsdk.doManualCalibrationOverTCPIP(
  address: '10.0.0.100', 
  port: 9100 //optional
)

Get printer settings

zsdk.getPrinterSettingsOverTCPIP(
  address: '10.0.0.100', 
  port: 9100 //optional
).then(value) {
 final printerSettings = PrinterResponse.fromMap(value).settings;
};

Set printer settings

zsdk.setPrinterSettingsOverTCPIP(
  address: '10.0.0.100', 
  port: 9100, //optional
  settings: PrinterSettings(
    darkness: 10,
    printSpeed: 6,
    tearOff: 0,
    mediaType: MediaType.MARK,
    printMethod: PrintMethod.DIRECT_THERMAL,
    printWidth: 568,
    labelLength: 1202,
    labelLengthMax: 39,
    zplMode: ZPLMode.ZPL_II,
    powerUpAction: PowerUpAction.NO_MOTION,
    headCloseAction: HeadCloseAction.NO_MOTION,
    labelTop: 0,
    leftPosition: 0,
    printMode: PrintMode.TEAR_OFF,
    reprintMode: ReprintMode.OFF,
  )
).then(value) {
  final printerResponse = PrinterResponse.fromMap(value);
  if(printerResponse.errorCode == ErrorCode.SUCCESS) {
    //Do something
  } else {
    Status status = printerResponse.statusInfo.status;
    Cause cause = printerResponse.statusInfo.cause;
    //Do something
  }
}

Reset printer settings

zsdk.setPrinterSettingsOverTCPIP(
  address: '10.0.0.100', 
  port: 9100, //optional
  settings: PrinterSettings.defaultSettings()
).then(value) {
   final printerResponse = PrinterResponse.fromMap(value);
   if(printerResponse.errorCode == ErrorCode.SUCCESS) {
     //Do something
   } else {
     Status status = printerResponse.statusInfo.status;
     Cause cause = printerResponse.statusInfo.cause;
     //Do something
   }
 }

Check printer status

zsdk.checkPrinterStatusOverTCPIP(
  address: '10.0.0.100', 
  port: 9100, //optional
).then(value) {
   final printerResponse = PrinterResponse.fromMap(value);
   Status status = printerResponse.statusInfo.status;
   print(status);
   if(printerResponse.errorCode == ErrorCode.SUCCESS) {
     //Do something 
   } else {
     Cause cause = printerResponse.statusInfo.cause;
     print(cause);
   }
 }

Reboot printer

zsdk.rebootPrinter(
  address: '10.0.0.100', 
  port: 9100, //optional
).then(value) {
   final printerResponse = PrinterResponse.fromMap(value);
   Status status = printerResponse.statusInfo.status;
   print(status);
   if(printerResponse.errorCode == ErrorCode.SUCCESS) {
     //Do something 
   } else {
     Cause cause = printerResponse.statusInfo.cause;
     print(cause);
   }
 }

Print zpl file

zsdk.printZplFileOverTCPIP(
  filePath: '/path/to/file.pdf',
  address: '10.0.0.100', 
  port: 9100, //optional
).then(value) {
   final printerResponse = PrinterResponse.fromMap(value);
   Status status = printerResponse.statusInfo.status;
   print(status);
   if(printerResponse.errorCode == ErrorCode.SUCCESS) {
     //Do something 
   } else {
     Cause cause = printerResponse.statusInfo.cause;
     print(cause);
   }
 }

Print zpl data

zsdk.printZplDataOverTCPIP(
  data: '^XA^FO17,16^GB379,371,8^FS^FT65,255^A0N,135,134^FDTEST^FS^XZ',
  address: '10.0.0.100', 
  port: 9100, //optional
).then(value) {
   final printerResponse = PrinterResponse.fromMap(value);
   Status status = printerResponse.statusInfo.status;
   print(status);
   if(printerResponse.errorCode == ErrorCode.SUCCESS) {
     //Do something 
   } else {
     Cause cause = printerResponse.statusInfo.cause;
     print(cause);
   }
 }

Print pdf file

zsdk.printPdfFileOverTCPIP(
  filePath: '/path/to/file.pdf',
  address: '10.0.0.100', 
  port: 9100, //optional
).then(value) {
   final printerResponse = PrinterResponse.fromMap(value);
   Status status = printerResponse.statusInfo.status;
   print(status);
   if(printerResponse.errorCode == ErrorCode.SUCCESS) {
     //Do something 
   } else {
     Cause cause = printerResponse.statusInfo.cause;
     print(cause);
   }
 }

search for bluetooth printers

zsdk.findPrintersOverBluetooth()
//use the printerFound callback to collect the found printers

Check the example code for more details

Tested Zebra Devices

  • Zebra ZT411
  • Zebra ZD500 Series
  • ZD620
  • ZQ620
  • Zebra ZD421

About

Adds bluetooth printing to luis901101/zsdk

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 47.2%
  • Dart 32.5%
  • Java 19.0%
  • Other 1.3%