Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I print with windows phone 8 using Bluetooth to a portable printer?

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?

like image 744
ngonzalez Avatar asked Jan 04 '13 18:01

ngonzalez


2 Answers

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));
            }
        }
like image 193
Fontanka16 Avatar answered Sep 20 '22 15:09

Fontanka16


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:

Quote

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.

like image 39
JustinAngel Avatar answered Sep 20 '22 15:09

JustinAngel