Click or drag to resize

PrinterUtil Class

Numerous utilities to simplify printer operations.
Inheritance Hierarchy
SystemObject
  Zebra.Sdk.PrinterPrinterUtil

Namespace:  Zebra.Sdk.Printer
Assembly:  SdkApi_Core (in SdkApi_Core.dll) Version: 2.13.898
Syntax
public class PrinterUtil

The PrinterUtil type exposes the following members.

Methods
  NameDescription
Public methodStatic memberConvertGraphic(String, ZebraImageI, Stream)
Encodes supplied image in either ZPL or CPCL after dithering and resizing.
Public methodStatic memberConvertGraphic(String, ZebraImageI, Int32, Int32, Stream)
Encodes supplied image in either ZPL or CPCL after dithering and resizing.
Public methodStatic memberCreateBackup
Create a backup of your printer's settings, alerts, and files.
Public methodStatic memberCreateProfile
Create a profile of your printer's settings, alerts, and files for cloning to other printers.
Public methodStatic memberDeleteFile
Deletes file(s) from the printer and reports what files were actually removed.
Public methodStatic memberDeleteFileReportDeleted
Deletes file(s) from the printer and reports what files were actually removed.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodStatic memberGetCurrentStatus
Returns a new instance of PrinterStatus that can be used to determine the status of a printer.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodStatic memberGetObjectFromPrinter(String, String)
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
Public methodStatic memberGetObjectFromPrinter(Stream, String, String)
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
Public methodStatic memberGetObjectFromPrinterViaFtp(String, String, String)
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
Public methodStatic memberGetObjectFromPrinterViaFtp(Stream, String, String, String)
Retrieves a file from the printer's file system and returns the contents of that file as a byte[].
Public methodStatic memberGetOdometerStatus
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.
Public methodStatic memberGetPortStatus
Retrieves a list of currently open tcp ports on the printer.
Public methodStatic memberGetPrinterStatus
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.
Public methodStatic memberGetSettingsFromPrinter
Retrieve all settings and their attributes from the specified printer.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodStatic memberListFiles
Retrieves the names of the files which are stored on the device.
Public methodStatic memberLoadBackup(String, String)
Takes settings, alerts, and files from a backup, and applies them to a printer.
Public methodStatic memberLoadBackup(String, String, Boolean)
Takes settings, alerts, and files from a backup, and applies them to a printer.
Public methodStatic memberLoadProfile(String, String, FileDeletionOption)
Takes settings, alerts, and files from a profile, and applies them to a printer.
Public methodStatic memberLoadProfile(String, String, FileDeletionOption, Boolean)
Takes settings, alerts, and files from a profile, and applies them to a printer.
Public methodStatic memberPrintConfigLabel
Causes the specified printer to print a configuration label.
Public methodStatic memberPrintDirectoryLabel
Causes the specified printer to print a directory listing of all the files saved on the printer.
Public methodStatic memberPrintNetworkConfigLabel
Causes the specified printer to print a network configuration label.
Public methodStatic memberQuickStatus
Retrieves the quick status of the printer.
Public methodStatic memberResetNetwork
Resets the network of the specified printer.
Public methodStatic memberResetPrinter
Resets the specified printer.
Public methodStatic memberRestoreNetworkDefaults
Restores the printer's network settings to their factory default configuration.
Public methodStatic memberRestorePrinterDefaults
Restores the printer's settings to their factory default configuration.
Public methodStatic memberSendContents(String, Stream)
Send contents of data directly to the device specified via connectionString using UTF-8 encoding.
Public methodStatic memberSendContents(String, String)
Send contents of data directly to the device specified via connectionString using UTF-8 encoding.
Public methodStatic memberSendContents(String, Stream, String)
Send contents of data directly to the device specified via connectionString using encoding.
Public methodStatic memberSendContents(String, String, String)
Send contents of data directly to the device specified via connectionString using encoding.
Public methodStatic memberSendJSON
Send contents of data directly to the device specified via connectionString using encoding.
Public methodStatic memberSetClock
Set the RTC time and date on the printer.
Public methodStatic memberStoreFile
Stores the file on the printer at the specified location and name using any required file wrappers.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUpdateFirmware
Update the printer firmware.
Top
Examples
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");
        }
    }
}
See Also