Link to home
Start Free TrialLog in
Avatar of SaltyDawg
SaltyDawgFlag for United States of America

asked on

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?
Avatar of SaltyDawg
SaltyDawg
Flag of United States of America image

ASKER

       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");
        }
ASKER CERTIFIED SOLUTION
Avatar of thekua
thekua

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.