Print using EPL2 in C#

I am trying to print to a Zebra Thermal Printer TLP 3742 in C Sharp. I am very unfamiliar with EPL2 Command Language. Here is what I have so far:

        SerialPort ComPort1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
        public void SendData()
        {
            try
            {
                using (ComPort1)
                {
                    // Open the port for communications
                    ComPort1.Open();
                    // Initialize Printer
                    InitSerialPrinter(ComPort1);
                    str = "50,50,0,4,1,1,N,\"50006854160000023B\"";
                    //ComPort1.Write(str);
                    // Close the port
                    ComPort1.Close();
                }
            }
            catch(Exception)
            {
                MessageBox.Show("No Serial");
            }
        }

        private void InitShippingPrinter(SerialPort m_pPortCom2)
        {
            SendCommandToPrinter(m_pPortCom2, "\nN");
            SendCommandToPrinter(m_pPortCom2, "D7");
            SendCommandToPrinter(m_pPortCom2, "S2");
            SendCommandToPrinter(m_pPortCom2, "ZT");
            SendCommandToPrinter(m_pPortCom2, "Q1800,36");
            SendCommandToPrinter(m_pPortCom2, "q1200");
        }

I have the manual but still unsure what to do. Could someone view this code and let me know what I'm doing wrong?
LVL 1
SaltyDawgAsked:
Who is Participating?
 
thekuaConnect With a Mentor Commented:
One of the extra bits you have to do is send the command for print one copy (P1). You need to add that to the end of your command string.

We created a C# library to hide the EPL2 language that you might want to consider using. It prints via the windows print queue (so no need for COM opening/closing in code) and uses meaningful names instead of the difficult-to-understand EPL2 language. Feel free to check it out and leave comments at http://codeplex.com/sharpzebra. It's released under the MIT licence.

Good luck!
0
 
SaltyDawgAuthor Commented:
       private void InitSerialPrinter(SerialPort m_pPortCom1)
        {
            SendCommandToPrinter(m_pPortCom1, "\nN");
            SendCommandToPrinter(m_pPortCom1, "D7");
            SendCommandToPrinter(m_pPortCom1, "S1");
            SendCommandToPrinter(m_pPortCom1, "ZT");
            SendCommandToPrinter(m_pPortCom1, "Q450,36");
            SendCommandToPrinter(m_pPortCom1, "q900");
        }
0
 
SaltyDawgAuthor Commented:
That was exactly it. I had everything correct up to the point where I did not send the command to print.

I added this:

                //Command Printer to Print
                tPrinter.ComPortData(ComPort2, "P1");

and it's working now, Thanks.
0
All Courses

From novice to tech pro — start learning today.