PrinterUtil Class |
Namespace: Zebra.Sdk.Printer
The PrinterUtil type exposes the following members.
Name | Description | |
---|---|---|
ConvertGraphic(String, ZebraImageI, Stream) |
Encodes supplied image in either ZPL or CPCL after dithering and resizing.
| |
ConvertGraphic(String, ZebraImageI, Int32, Int32, Stream) |
Encodes supplied image in either ZPL or CPCL after dithering and resizing.
| |
CreateBackup |
Create a backup of your printer's settings, alerts, and files.
| |
CreateProfile |
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
| |
DeleteFile |
Deletes file(s) from the printer and reports what files were actually removed.
| |
DeleteFileReportDeleted |
Deletes file(s) from the printer and reports what files were actually removed.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
GetCurrentStatus |
Returns a new instance of PrinterStatus that can be used to determine the status of a printer.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetObjectFromPrinter(String, String) |
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
| |
GetObjectFromPrinter(Stream, String, String) |
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
| |
GetObjectFromPrinterViaFtp(String, String, String) |
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
| |
GetObjectFromPrinterViaFtp(Stream, String, String, String) |
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
| |
GetOdometerStatus |
Retrieves status of the printer odometer which includes the total print length, head clean counter, label dot
length, head new, latch open counter, and both user resettable counters.
| |
GetPortStatus |
Retrieves a list of currently open tcp ports on the printer.
| |
GetPrinterStatus |
Retrieves status of the printer which includes any error messages currently set along with the number of labels
remaining in queue, number of labels remaining in batch, and whether or not a label is currently being processed.
| |
GetSettingsFromPrinter |
Retrieve all settings and their attributes from the specified printer.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ListFiles |
Retrieves the names of the files which are stored on the device.
| |
LoadBackup(String, String) |
Takes settings, alerts, and files from a backup, and applies them to a printer.
| |
LoadBackup(String, String, Boolean) |
Takes settings, alerts, and files from a backup, and applies them to a printer.
| |
LoadProfile(String, String, FileDeletionOption) |
Takes settings, alerts, and files from a profile, and applies them to a printer.
| |
LoadProfile(String, String, FileDeletionOption, Boolean) |
Takes settings, alerts, and files from a profile, and applies them to a printer.
| |
PrintConfigLabel |
Causes the specified printer to print a configuration label.
| |
PrintDirectoryLabel |
Causes the specified printer to print a directory listing of all the files saved on the printer.
| |
PrintNetworkConfigLabel |
Causes the specified printer to print a network configuration label.
| |
QuickStatus |
Retrieves the quick status of the printer.
| |
ResetNetwork |
Resets the network of the specified printer.
| |
ResetPrinter |
Resets the specified printer.
| |
RestoreNetworkDefaults |
Restores the printer's network settings to their factory default configuration.
| |
RestorePrinterDefaults |
Restores the printer's settings to their factory default configuration.
| |
SendContents(String, Stream) |
Send contents of data directly to the device specified via connectionString using UTF-8 encoding.
| |
SendContents(String, String) |
Send contents of data directly to the device specified via connectionString using UTF-8 encoding.
| |
SendContents(String, Stream, String) |
Send contents of data directly to the device specified via connectionString using encoding.
| |
SendContents(String, String, String) |
Send contents of data directly to the device specified via connectionString using encoding.
| |
SendJSON |
Send contents of data directly to the device specified via connectionString using encoding.
| |
SetClock |
Set the RTC time and date on the printer.
| |
StoreFile |
Stores the file on the printer at the specified location and name using any required file wrappers.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
UpdateFirmware |
Update the printer firmware.
|
using System; using Zebra.Sdk.Printer; public class PrinterUtilExample { private static string CONNECTION_STRING = "172.30.16.135"; public static void Main(string[] args) { // Create a few files on the printer SendContentsExample(); // List the files just created ListFilesExample(); // Silently delete some of the files DeleteFilesExample(); // List the remaining files ListFilesExample(); // Verbosely delete the rest of the files DeleteFilesVerboseExample(); // List the remaining files ListFilesExample(); } private static void SendContentsExample() { PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST1.ZPL^FO100,100^A0N,30,30^FDZSDK_Test1.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST2.ZPL^FO100,100^A0N,30,30^FDZSDK_Test2.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST3.ZPL^FO100,100^A0N,30,30^FDZSDK_Test3.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST4.ZPL^FO100,100^A0N,30,30^FDZSDK_Test4.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST11.ZPL^FO100,100^A0N,30,30^FDZSDK_Test11.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST12.ZPL^FO100,100^A0N,30,30^FDZSDK_Test12.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST22.ZPL^FO100,100^A0N,30,30^FDZSDK_Test22.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST33.ZPL^FO100,100^A0N,30,30^FDZSDK_Test33.zpl^FS^XZ"); PrinterUtil.SendContents(CONNECTION_STRING, "^XA^DFR:ZSDK_TEST44.ZPL^FO100,100^A0N,30,30^FDZSDK_Test44.zpl^FS^XZ"); } private static void ListFilesExample() { string[] filesOnE = PrinterUtil.ListFiles(CONNECTION_STRING, "R:ZSDK_TEST*.*"); Console.WriteLine("--- List of Files on R: ---"); foreach (string thisFile in filesOnE) { Console.WriteLine($" - {thisFile}"); } Console.WriteLine("--- End of List ---"); } private static void DeleteFilesExample() { Console.WriteLine("Deleting R:ZSDK_TEST1*.ZPL..."); PrinterUtil.DeleteFile(CONNECTION_STRING, "R:ZSDK_TEST1*.ZPL"); } private static void DeleteFilesVerboseExample() { Console.WriteLine("Verbosely Deleting R:ZSDK_TEST*.ZPL..."); string[] filesDeleted = PrinterUtil.DeleteFileReportDeleted(CONNECTION_STRING, "R:ZSDK_TEST*.ZPL"); foreach (string thisDeletedFile in filesDeleted) { Console.WriteLine($" - {thisDeletedFile} deleted"); } } }
using Android.App; using Android.OS; using Android.Views; using Android.Widget; using System; using System.Threading.Tasks; using Zebra.Sdk.Printer; public class PrinterUtilExample : Activity { protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); LinearLayout layout = (LinearLayout)View.Inflate(this, Android.Resource.Layout.ActivityListItem, null); layout.Orientation = Orientation.Vertical; Button buttonPrint = new Button(this) { Text = "Run Printer Util Example", LayoutParameters = new ViewGroup.LayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent)) }; layout.AddView(buttonPrint); SetContentView(layout); buttonPrint.Click += async (sender, e) => { await Task.Run(() => { // The possible inputs to the one-line CSV printing function(s) string destinationDevice = "1.2.3.4"; // Create a few files on the printer SendContentsExample(destinationDevice); // List the files just created ListFilesExample(destinationDevice); // Silently delete some of the files DeleteFilesExample(destinationDevice); // List the remaining files ListFilesExample(destinationDevice); // Verbosely delete the rest of the files DeleteFilesVerboseExample(destinationDevice); // List the remaining files ListFilesExample(destinationDevice); }); }; } private void SendContentsExample(string destinationDevice) { PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST1.ZPL^FO100,100^A0N,30,30^FDZSDK_Test1.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST2.ZPL^FO100,100^A0N,30,30^FDZSDK_Test2.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST3.ZPL^FO100,100^A0N,30,30^FDZSDK_Test3.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST4.ZPL^FO100,100^A0N,30,30^FDZSDK_Test4.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST11.ZPL^FO100,100^A0N,30,30^FDZSDK_Test11.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST12.ZPL^FO100,100^A0N,30,30^FDZSDK_Test12.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST22.ZPL^FO100,100^A0N,30,30^FDZSDK_Test22.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST33.ZPL^FO100,100^A0N,30,30^FDZSDK_Test33.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST44.ZPL^FO100,100^A0N,30,30^FDZSDK_Test44.zpl^FS^XZ"); } private void ListFilesExample(string destinationDevice) { string[] filesOnE = PrinterUtil.ListFiles(destinationDevice, "R:ZSDK_TEST*.*"); Console.WriteLine("--- List of Files on R: ---"); foreach (string thisFile in filesOnE) { Console.WriteLine($" - {thisFile}"); } Console.WriteLine("--- End of List ---"); } private void DeleteFilesExample(string destinationDevice) { Console.WriteLine("Deleting R:ZSDK_TEST1*.ZPL..."); PrinterUtil.DeleteFile(destinationDevice, "R:ZSDK_TEST1*.ZPL"); } private void DeleteFilesVerboseExample(string destinationDevice) { Console.WriteLine("Verbosely Deleting R:ZSDK_TEST*.ZPL..."); string[] filesDeleted = PrinterUtil.DeleteFileReportDeleted(destinationDevice, "R:ZSDK_TEST*.ZPL"); foreach (string thisDeletedFile in filesDeleted) { Console.WriteLine($" - {thisDeletedFile} deleted"); } } }
using CoreGraphics; using System; using System.Threading.Tasks; using UIKit; using Zebra.Sdk.Printer; public class PrinterUtilExample : UIViewController { public PrinterUtilExample(IntPtr handle) : base(handle) { UIButton testButton = new UIButton(UIButtonType.System) { Frame = new CGRect(25, 25, 300, 150) }; testButton.SetTitle("Run Printer Util Example", UIControlState.Normal); testButton.TouchUpInside += async (sender, e) => { await Task.Run(() => { // The possible inputs to the one-line CSV printing function(s) string destinationDevice = "1.2.3.4"; // Create a few files on the printer SendContentsExample(destinationDevice); // List the files just created ListFilesExample(destinationDevice); // Silently delete some of the files DeleteFilesExample(destinationDevice); // List the remaining files ListFilesExample(destinationDevice); // Verbosely delete the rest of the files DeleteFilesVerboseExample(destinationDevice); // List the remaining files ListFilesExample(destinationDevice); }); }; View.AddSubview(testButton); } private void SendContentsExample(string destinationDevice) { PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST1.ZPL^FO100,100^A0N,30,30^FDZSDK_Test1.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST2.ZPL^FO100,100^A0N,30,30^FDZSDK_Test2.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST3.ZPL^FO100,100^A0N,30,30^FDZSDK_Test3.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST4.ZPL^FO100,100^A0N,30,30^FDZSDK_Test4.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST11.ZPL^FO100,100^A0N,30,30^FDZSDK_Test11.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST12.ZPL^FO100,100^A0N,30,30^FDZSDK_Test12.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST22.ZPL^FO100,100^A0N,30,30^FDZSDK_Test22.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST33.ZPL^FO100,100^A0N,30,30^FDZSDK_Test33.zpl^FS^XZ"); PrinterUtil.SendContents(destinationDevice, "^XA^DFR:ZSDK_TEST44.ZPL^FO100,100^A0N,30,30^FDZSDK_Test44.zpl^FS^XZ"); } private void ListFilesExample(string destinationDevice) { string[] filesOnE = PrinterUtil.ListFiles(destinationDevice, "R:ZSDK_TEST*.*"); Console.WriteLine("--- List of Files on R: ---"); foreach (string thisFile in filesOnE) { Console.WriteLine($" - {thisFile}"); } Console.WriteLine("--- End of List ---"); } private void DeleteFilesExample(string destinationDevice) { Console.WriteLine("Deleting R:ZSDK_TEST1*.ZPL..."); PrinterUtil.DeleteFile(destinationDevice, "R:ZSDK_TEST1*.ZPL"); } private void DeleteFilesVerboseExample(string destinationDevice) { Console.WriteLine("Verbosely Deleting R:ZSDK_TEST*.ZPL..."); string[] filesDeleted = PrinterUtil.DeleteFileReportDeleted(destinationDevice, "R:ZSDK_TEST*.ZPL"); foreach (string thisDeletedFile in filesDeleted) { Console.WriteLine($" - {thisDeletedFile} deleted"); } } }