I am developing an app on windows phone 8. This app must print tickets using a mobile printer like a Zebra MZ 220 Mobile Printer.
I have been googling trying to get information about printing to a bluetooth printer using windows phone 8 but there is not to much information.
My fear is to have to start a new development in another mobile operating system like android, just because wp8 does not support printing on bluetooth.
Is there any example about it? Is there any portable printer compatible with Microsoft Windows Phone 8?
This code works for me on a Zebra 420 paired with a Nokia 820.
private async void PrintStuff()
{
string command = "^XA^LH30,30^F020,10^AD^FDHello World^FS^XZ";
Byte[] buffer = new byte[command.Length];
buffer = StringToAscii(command);
PeerFinder.AlternateIdentities["Bluetooth:Paired"] = "";
var pairedDevices = await PeerFinder.FindAllPeersAsync();
if (pairedDevices.Count == 0)
{
Debug.WriteLine("No paired devices were found.");
}
else
{
PeerInformation selectedDevice = pairedDevices[0];
StreamSocket socket = new StreamSocket();
await socket.ConnectAsync(selectedDevice.HostName, "1");
await socket.OutputStream.WriteAsync(WindowsRuntimeBufferExtensions.AsBuffer(buffer));
}
}
There are already examples of other BT-SPP printers on WP8. It should be possible to connect to your "Zebra" bluetooth printer and send it jobs. Based on this documentation is supports the BT-SPP (bluetooth serial port portocol) that WP8 supports:
One thing you're going to have to figure out first is the specifics of the input/output byte packets expected by your device. SPP just sends and receives bytes over BT, you need to know the specific format your device needs. For example in my Mindwave Headset WP8 BT SDK I had to find this document that has the BT-SPP protocol for that particular device. There seem to be quite a few OSS projects for Zebra printers, so you might want to see if those have those formats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With