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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
thekuaCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.