3 Replies Latest reply on Oct 7, 2015 10:38 AM by Robin West

    imz320 Zebra Designer printing problem

    Panicos Makrides

       

      We have an issue regarding printing and we were wondering wither you would be able to assist for a solution.

       

      Firstly, I am using Zebra Designer to create a ZPL II file.

       

      Secondly, I’m creating the ZPL file using the “print to file” command.

       

       

       

      The main issue is that when the file is sent  to imz320 using  Zebra Setup Utilities with no issues whatsoever,

       

      however when the file is sent via C# no printing occurs.

       

       

       

      We are using Bluetooth connection in order to communicate with the zebra mobile printer.

       

       

       

      Here is a small example of my source code:

       

       

       

      ZebraSerialPort port = new ZebraSerialPort("COM4", 115200, 8, Parity.None, StopBits.One, Handshake.None, -1, -1);

       

      port.Open();

       

       

       

                          FileStream fs = new FileStream(@"My Documents\zpl1.prn", FileMode.Open);

       

      fs.Flush();

       

       

       

      int nLength = Convert.ToInt32(fs.Length);

       

      BinaryReader br = new BinaryReader(fs);

       

      Byte[] bytes = new Byte[fs.Length];

       

      bytes = br.ReadBytes(nLength);

       

       

       

       

       

      port.Write(bytes, 0, nLength);

       

       

       

      Thread.Sleep(2000);

       

      Port.close;

       

        • Re: imz320 Zebra Designer printing problem
          Robin West

          Hi Panicos,

          Is the ZebraSerialPort essentially a C# SerialPort object (System.IO)?  Have you verified the Serial port has been set up correctly on the OS?  I use TeraTerm on my PC to make sure the serial port has been set up by sending "~HI" without quotes and seeing the response.  Printer should respond with printer model number, firmware version, etc.

          If so, have you verified the file is being converted to bytes correctly?  I use the code:

               private StringBuilder GetFile(string fileName)

                {

                   StringBuilder sb = new StringBuilder();

                   if (File.Exists(fileName))

                   {

                      string[] lines = System.IO.File.ReadAllLines(@fileName);

                      foreach (string line in lines)

                         sb.Append(newline);

                   }

                   return sb;

                }

          byte [] buffer = convertToBuffer(GetFile(@"My Documents\zpl1.prn"));


          If your code is for a mobile device, which one and what IDE are you using?

          Robin

          1 of 1 people found this helpful
          • Re: imz320 Zebra Designer printing problem
            Panicos Makrides

            Hello Robin and thanks for your help,


            ZebraSerialPort is an object derived from serialport.Is implemented while using zebras sdk.

             

            We do print via usb (imz320 connected with usb with a pc) by sending a file which contains zpl script to the printer.

             

            Our issue is while trying to send same file via bluetooth connection.Our file is approx 90KB. We sent smaller file and worked.

             

            Any ideas?


            You can also find attached two prn files, ZPL1 prints fine ZPL2 no printing.

              • Re: Re: imz320 Zebra Designer printing problem
                Robin West

                Hi Panicos, Sorry for the delay in responding.

                Bluetooth is a slow communication protocol and has interesting ways of handling flow control.  I recommend for larger files, to "chunk them up."

                 

                Starting with your code you have a byte[], so try sending only small amounts at a time. Don't worry about the delay to the printer, it can handle it.

                Replace the line "port.Write(bytes, 0, nLength);" with something like below.  This will send 1000 bytes at a time.  You may have to adjust the sleep timing depending on the printer and other factors.  I broke it out so it was easy to see what was happening:

                 

                int chunk = 1000;

                int lengthLeft = nLength;

                int index = 0;

                while (lengthLeft > 0)

                {

                    if (lengthLeft < chunk )

                          chunk = lengthLeft;

                    port.Write(bytes, index, chunk);

                    index += chunk;

                    lengthLeft -= chunk;

                    Thread.Sleep(200);

                }

                Thread.Sleep(200);