简体   繁体   中英

How to send Font via Bluetooth to Zebra printer

I must send a Font file to my printer Zebra RW420 via bluetooth. Im using Zebra Windows Mobile SDK, but can't find any way to send and store it on printer. I could do it manually by Label Vista but It must be done in 200+ printers.

Anyone have any suggestion or know what method from the SDK I could use?

Thanks in advance.

CISDF is the correct answer, it's probably the checksum value that you are computing that is incorrect. I put a port sniffer on my RW420 attached to a USB port and found this to work. I actually sent some PCX images to the printer, then used them in a label later on.

! CISDF
<filename>
<size>
<cksum>
<data>

There is a CRLF at the end of the 1st four lines. Using 0000 as the checksum causes the printer to ignore any checksum verification (I found some really obscure references to this in some ZPL manuals, tried it and it worked). <filename> is the 8.3 name of the file as it will be stored in the file system on the printer and <size> is the size of the file, 8 characters long and formatted as a hexadecimal number. <cksum> is the two's complement of the sum of the data bytes as the checksum. <data> is, of course, the contents of the file to be stored on the printer.

Here is the actual C# code that I used to send my sample images to the printer:

// calculate the checksum for the file

// get the sum of all the bytes in the data stream
UInt16 sum = 0;
for (int i = 0; i < Properties.Resources.cmlogo.Length; i++)
{
  sum += Convert.ToUInt16(Properties.Resources.cmlogo[ i]);
}

// compute the two's complement of the checksum
sum = (Uint16)~sum;
sum += 1;

// create a new printer
MP2Bluetooth bt = new MP2Bluetooth();

// connect to the printer
bt.ConnectPrinter("<MAC ADDRESS>", "<PIN>");

// write the header and data to the printer
bt.Write("! CISDF\r\n");
bt.Write("cmlogo.pcx\r\n");
bt.Write(String.Format("{0:X8}\r\n", Properties.Resources.cmlogo.Length));
bt.Write(String.Format("{0:X4}\r\n", sum));  // checksum, 0000 => ignore checksum
bt.Write(Properties.Resources.cmlogo);

// gracefully close our connection and disconnect
bt.Close();
bt.DisconnectPrinter();

MP2Bluetooth is a class we use internally to abstract BT connections and communications - you have your own as well, I'm sure!

You can use the SDK to send any kind of data. A Zebra font is just a font file with a header on it. So if you capture the output cpf file from Label Vista, you can send that file from the SDK. Just create a connection, and call write(byte[]) with the contents of the file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM