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

我与影子孤独终老i 提交于 2019-12-05 00:26:27

问题


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?


回答1:


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));
            }
        }



回答2:


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.




回答3:


I'm working on an Android app (Windows Phone later) that uses a Bluetooth printer and it is simple and I found it can be done with any OS that has Bluetooth capabilities. Each printer is a little different to connect to, but once you can get connected, you just pass data through serial. In my case, I'm using an image and sending the bytes as a string.




回答4:


Zebra provides an API for Windows Mobile .NET framework for printing in WinMo .NET



来源:https://stackoverflow.com/questions/14162889/can-i-print-with-windows-phone-8-using-bluetooth-to-a-portable-printer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!