简体   繁体   English

如何通过蓝牙将字体发送到Zebra打印机

[英]How to send Font via Bluetooth to Zebra printer

I must send a Font file to my printer Zebra RW420 via bluetooth. 我必须通过蓝牙将一个Font文件发送到我的打印机Zebra RW420。 Im using Zebra Windows Mobile SDK, but can't find any way to send and store it on printer. 我使用Zebra Windows Mobile SDK,但无法找到任何方式将其发送并存储在打印机上。 I could do it manually by Label Vista but It must be done in 200+ printers. 我可以通过Label Vista手动完成,但必须在200多台打印机中完成。

Anyone have any suggestion or know what method from the SDK I could use? 任何人有任何建议或知道我可以使用的SDK中的方法是什么?

Thanks in advance. 提前致谢。

CISDF is the correct answer, it's probably the checksum value that you are computing that is incorrect. CISDF是正确的答案,它可能是您正在计算的校验和值不正确。 I put a port sniffer on my RW420 attached to a USB port and found this to work. 我把一个端口嗅探器放在连接到USB端口的RW420上,发现这个工作正常。 I actually sent some PCX images to the printer, then used them in a label later on. 我实际上已经将一些PCX图像发送到打印机,然后在标签中使用它们。

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

There is a CRLF at the end of the 1st four lines. 在前四行的末尾有一个CRLF。 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). 使用0000作为校验和会导致打印机忽略任何校验和验证(我在一些ZPL手册中发现了一些非常模糊的引用,试过它并且它有效)。 <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. <filename>是文件的8.3名称,因为它将存储在打印机的文件系统中,<size>是文件的大小,长度为8个字符,格式为十六进制数。 <cksum> is the two's complement of the sum of the data bytes as the checksum. <cksum>是作为校验和的数据字节总和的二进制补码。 <data> is, of course, the contents of the file to be stored on the printer. 当然,<data>是要存储在打印机上的文件的内容。

Here is the actual C# code that I used to send my sample images to the printer: 这是我用来将示例图像发送到打印机的实际C#代码:

// 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! MP2Bluetooth是我们内部用来抽象BT连接和通信的类 - 你也有自己的,我敢肯定!

You can use the SDK to send any kind of data. 您可以使用SDK发送任何类型的数据。 A Zebra font is just a font file with a header on it. Zebra字体只是一个带有标题的字体文件。 So if you capture the output cpf file from Label Vista, you can send that file from the SDK. 因此,如果从Label Vista捕获输出cpf文件,则可以从SDK发送该文件。 Just create a connection, and call write(byte[]) with the contents of the file 只需创建一个连接,并使用该文件的内容调用write(byte[])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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