Clare Barrington
Clare Barrington

Reputation: 1155

PNG Zebra Printer Commands - What do they mean?

I've copied this from another question (highest marked answer). When running it, I'm not receiving any errors but its also not printing anything.

My PNG - Personal content removed

enter image description here

My question is, what are the codes they use?

zplToSend

  1. "^XA" - Start
  2. "^MNN" - Can't see what this is
  3. "^LL500" - The image I have is separated by gaps/spaces etc so do I need this?
  4. "~DYE:LOGO,P,P," - Seems to used to store it to permanent flash memory, unsure if I am keen on this. I want to print straight away, why would you want it to be permanent
  5. binaryData.Length - Why is this the binaryData.Length and not the zplImageData.Length
  6. zplImageData
  7. "^XZ" - Ends

printImage

  1. "^XA" - Start
  2. ^IME:LOGO.PNG - is this a reference to the ~DYE:Logo?
  3. ^XZ" - End

        var ipAddress = "192.168.1.30";
        var port = 9100;
    
        string zplImageData = string.Empty;
        //Make sure no transparency exists. I had some trouble with this. This PNG has a white background
        string filePath = @"C:\Users\Path\To\Logo.png";
        byte[] binaryData = System.IO.File.ReadAllBytes(filePath);
        foreach (Byte b in binaryData)
        {
            string hexRep = String.Format("{0:X}", b);
            if (hexRep.Length == 1)
                hexRep = "0" + hexRep;
            zplImageData += hexRep;
        }
        string zplToSend = "^XA" + "^MNN" + "^LL500" + "~DYE:LOGO,P,P," + binaryData.Length + ",," + zplImageData + "^XZ";
        string printImage = "^XA^IME:LOGO.PNG^XZ";
    
        try
        {
            // Open connection
            System.Net.Sockets.TcpClient client = new System.Net.Sockets.TcpClient();
            client.Connect(ipAddress, port);
    
            // Write ZPL String to connection
            System.IO.StreamWriter writer = new System.IO.StreamWriter(client.GetStream(), Encoding.UTF8);
            writer.Write(zplToSend);
            writer.Flush();
            writer.Write(printImage);
            writer.Flush();
            // Close Connection
            writer.Close();
            client.Close();
        }
        catch (Exception ex)
        {
            // Catch Exception
        }
    

Also tired

    string zplToSend = "^XA" + "~DYR:LOGO,P,P," + binaryData.Length + ",," + zplImageData + "^XZ";
    string printImage = "^XA^FO0,0^IMR:LOGO.PNG^FS^XZ";

And:

        string zplToSend = "^XA" + "~DYR:LOGO,P,P," + binaryData.Length + ",," + zplImageData + "^XZ";
        string printImage = "^XA^ILR:LOGO.PNG^XZ";

None return an error and do not print.

Upvotes: 2

Views: 3948

Answers (1)

Clare Barrington
Clare Barrington

Reputation: 1155

PrintImage

^XA Start Format Description The ^XA command is used at the beginning of ZPL II code. It is the opening bracket and indicates the start of a new label format. This command is substituted with a single ASCII control character STX (control-B, hexadecimal 02). Format ^XA Comments Valid ZPL II format requires that label formats should start with the ^XA command and end with the ^XZ command.

^FO Field Origin Description The ^FO command sets a field origin, relative to the label home (^LH) position. ^FO sets the upper-left corner of the field area by defining points along the x-axis and y-axis independent of the rotation. Format ^FOx,y,z

  • x = x-axis location (in dots) Accepted Values: 0 to 32000 Default Value: 0
  • y = y-axis location (in dots) Accepted Values: 0 to 32000 Default Value: 0
  • z = justification The z parameter is only supported in firmware versions V60.14.x, V50.14.x, or later. Accepted Values: 0 = left justification 1 = right justification 2 = auto justification (script dependent) Default Value: last accepted ^FW value or ^FW default

^IM Image Move Description The ^IM command performs a direct move of an image from storage area into the bitmap. The command is identical to the ^XG command (Recall Graphic), except there are no sizing parameters. Format ^IMd:o.x

  • d = location of stored object Accepted Values: R:, E:, B:, and A: Default Value: search priority
  • o = object name Accepted Values: 1 to 8 alphanumeric characters Default Value: if a name is not specified, UNKNOWN is used
  • x = extension Fixed Value: .GRF, .PNG

^FS Field Separator Description The ^FS command denotes the end of the field definition. Alternatively, ^FS command can also be issued as a single ASCII control code SI (Control-O, hexadecimal 0F). Format ^FS

^XZ End Format Description The ^XZ command is the ending (closing) bracket. It indicates the end of a label format. When this command is received, a label prints. This command can also be issued as a single ASCII control character ETX (Control-C, hexadecimal 03). Format ^XZ Comments Label formats must start with the ^XA command and end with the ^XZ command to be in valid ZPL II format.

zplToSend

^MN Media Tracking Description This command specifies the media type being used and the black mark offset in dots. This bulleted list shows the types of media associated with this command:

  • Continuous Media – this media has no physical characteristic (such as a web, notch, perforation, black mark) to separate labels. Label length is determined by the ^LL command.
  • Continuous Media, variable length – same as Continuous Media, but if portions of the printed label fall outside of the defined label length, the label size will automatically be extended to contain them. This label length extension applies only to the current label. Note that ^MNV still requires the use of the ^LL command to define the initial desired label length.
  • Non-continuous Media – this media has some type of physical characteristic (such as web, notch, perforation, black mark) to separate the labels.

Format ^MNa,b

  • a = (required) media being used. Accepted Values:
    • N = continuous media
    • Y = non-continuous media web sensing
    • W = non-continuous media web sensing
    • M = non-continuous media mark sensing
    • A = auto-detects the type of media during calibration
    • V = continuous media, variable length
  • b = black mark offset in dots This sets the expected location of the media mark relative to the point of separation between documents. If set to 0, the media mark is expected to be found at the point of separation. (i.e., the perforation, cut point, etc.) All values are listed in dots. This parameter is ignored unless the a parameter is set to M. If this parameter is missing, the default value is used. Accepted Values: -80 to 283 for direct-thermal only printers -240 to 566 for 600 dpi printers -75 to 283 for KR403 printers -120 to 283 for all other printers Default Value: 0

~DY Download Objects Description The ~DY command downloads to the printer graphic objects or fonts in any supported format. This command can be used in place of ~DG for more saving and loading options. ~DY is the preferred command to download TrueType fonts on printers with firmware later than X.13. It is faster than ~DU. The ~DY command also supports downloading wireless certificate files. Format ~DYd:f,b,x,t,w,data

Note When using certificate files, your printer supports:

  • Using Privacy Enhanced Mail (PEM) formatted certificate files.

  • Using the client certificate and private key as two files, each downloaded separately.

  • Using exportable PAC files for EAP-FAST.

  • Zebra recommends using Linear sty

  • d = file location .NRD and .PAC files reside on E: in firmware versions V60.15.x, V50.15.x, or later. Accepted Values: R:, E:, B:, and A: Default Value: R:

  • f = file name Accepted Values: 1 to 8 alphanumeric characters Default Value: if a name is not specified, UNKNOWN is used

  • b = format downloaded in data field .TTE and .TTF are only supported in firmware versions V60.14.x, V50.14.x, or later. Accepted Values: A = uncompressed (ZB64, ASCII) B = uncompressed (.TTE, .TTF, binary) C = AR-compressed (used only by Zebra’s BAR-ONE® v5) P = portable network graphic (.PNG) - ZB64 encoded Default Value: a value must be specified

Upvotes: 1

Related Questions