1 of 1 people found this helpful
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();
string lines = System.IO.File.ReadAllLines(@fileName);
foreach (string line in lines)
byte  buffer = convertToBuffer(GetFile(@"My Documents\zpl1.prn"));
If your code is for a mobile device, which one and what IDE are you using?
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.
You can also find attached two prn files, ZPL1 prints fine ZPL2 no printing.
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;