Abe
Abe

Reputation: 326

Programmatic cutting on a ZPL printer from c#

I am developing a program in C# to process shipping requests with UPS, register them in the clients database and send the new labels to a networked ZPL printer.

We are working with a GX420T Zebra printer with a cutter. Printing labels works without issue via IP.

I am having an issue cutting the labels. The client wants each shipment's labels to be connected, but separated from the labels of other shipments. (ie. only cut after all the shipment's labels are printed) With a shipment of a single label the label is cut as expected. With shipments of multiple labels the cutter never runs.

        bool print = true; //true: If printing fails on the first label,
                           // do not try the rest.
                           //false: do not print

        //Set printer mode
        print = parseZPL.printZPL_IP(@"^XA^MMD^XZ");

        //Save and print Package labels
        foreach (XElement package in Packages)
        {   //Parse XML
            if (package.Name.LocalName == "PackageResults")
            {
                //Pulling Package and Shipping label information from XML
                string ShippingLabel = package.Element(ship + "ShippingLabel").Element(ship + "GraphicImage").Value;

                //convert string to Base64
                byte[] ZPLbytes = Convert.FromBase64String(ShippingLabel);

                if (print)
                {
                    print = parseZPL.printZPL_IP(System.Text.Encoding.ASCII.GetString(ZPLbytes));
                }
            }
        };

        if (print)
        {
            print = parseZPL.printZPL_IP(@"~JK");
        }

I tried adding a sleep() command before the ~JK command, with no success. I have scoured the ZPL Documentation without finding a solution that worked.

Any suggestions would be greatly appreciated. Thank you!

Upvotes: 2

Views: 4361

Answers (1)

Mark Warren
Mark Warren

Reputation: 1491

When printing a batch of labels, I think you need to set ^MMT (tearoff) at the start of the first label, and ^MMC (cut) at the start of the last label.

Upvotes: 2

Related Questions