0

In C# / Windows Forms, I need to print one example of ZPL on printer EpsonTM-T20 usb.

I only managed to print the code but it does not take the zpl format.

What do I need to do? Use a library, a plugin, a special command?

This is the code:

RawPrinterHelper .NET code to send ZPL to Zebra printers same code:

namespace WFZPL
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {

            string s = "^XA" +
                        "^FX Top section with logo, name and address." +
                        "^CF0,60" +
                        "^FO50,50^GB100,100,100^FS" +
                        "^FO75,75^FR^GB100,100,100^FS" +
                        "^FO93,93^GB40,40,40^FS" +
                        "^FO220,50^FDIntershipping, Inc.^FS" +
                        "^CF0,30" +
                        "^FO220,115^FD1000 Shipping Lane^FS" +
                        "^FO220,155^FDShelbyville TN 38102^FS" +
                        "^FO220,195^FDUnited States (USA)^FS" +
                        "^FO50,250^GB700,3,3^FS" +

                        "^FX Second section with recipient address and permit information." +
                        "^CFA,30" +
                        "^FO50,300^FDJohn Doe^FS" +
                        "^FO50,340^FD100 Main Street^FS" +
                        "^FO50,380^FDSpringfield TN 39021^FS" +
                        "^FO50,420^FDUnited States (USA)^FS" +
                        "^CFA,15" +
                        "^FO600,300^GB150,150,3^FS" +
                        "^FO638,340^FDPermit^FS" +
                        "^FO638,390^FD123456^FS" +
                        "^FO50,500^GB700,3,3^FS" +

                        "^FX Third section with bar code." +
                        "^BY5,2,270" +
                        "^FO100,550^BC^FD12345678^FS" +

                        "^FX Fourth section (the two boxes on the bottom)." +
                        "^FO50,900^GB700,250,3^FS" +
                        "^FO400,900^GB3,250,3^FS" +
                        "^CF0,40" +
                        "^FO100,960^FDCtr. X34B-1^FS" +
                        "^FO100,1010^FDREF1 F00B47^FS" +
                        "^FO100,1060^FDREF2 BL4H8^FS" +
                        "^CF0,190" +
                        "^FO470,955^FDCA^FS" +

                        "XZ";
          

            PrintDialog pd = new PrintDialog();
            pd.PrinterSettings = new System.Drawing.Printing.PrinterSettings();
            if (DialogResult.OK == pd.ShowDialog(this))
            {
                RawPrinterHelper.SendStringToPrinter(pd.PrinterSettings.PrinterName, s);
              
                MessageBox.Show("Data sent to printer.");
            }          
        }
    }
}
David Makogon
  • 67,251
  • 21
  • 140
  • 181
Larry
  • 9
  • 2
  • copy/paste the ZPL code on this website: http://staging.advanced-technology-group.com/ You will get this error "**ERROR: The ZPL is missing an ending ^XZ command.**" – Luuk May 23 '22 at 19:07
  • 1
    When adding the `^`, you will get this: https://i.stack.imgur.com/XxiWq.png – Luuk May 23 '22 at 19:21
  • ups sorry i forgot that ^ paste, But the printer is still not applying the zpl – Larry May 23 '22 at 19:29
  • Did the exact copy of the [linked stackoverflow message](https://stackoverflow.com/questions/2044676/net-code-to-send-zpl-to-zebra-printers) work? If the answer if YES, then you have some problem in your code, if this exact copy also "not works", you have a problem with your printer. – Luuk May 23 '22 at 19:38
  • I have used that command too "^XA^LH30,30\n^FO20,10^ADN,90,50^AD^FDHello World^FS\n^XZ" and the same thing happens, it prints it but ignores the zpl, :C – Larry May 23 '22 at 19:57
  • Does the printer manual tell you that it supports ZPL in the first place? From what I can find, it only supports ESC/POS, "the Epson original printer command system". – GSerg May 23 '22 at 21:42
  • thx for the info, The problem I see now is that I find very little information on how to program in ESC/POS C# – Larry May 23 '22 at 22:00

1 Answers1

-2

Not sure how you have your printer set up/configured. But if you want to send the raw text to the printer, you need to set it up as a generic text based driver. If it's using the driver that renders WYSIWYG from the PC, it's not going to work. Also, make sure your printer is set up to accept/interpret ZPL. It may not be native for Epson printers.

EdHayes3
  • 1,543
  • 1
  • 13
  • 30