简体   繁体   English

我可以使用蓝牙将便携式打印机的Windows Phone 8打印出来吗?

[英]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. 我正在Windows Phone 8上开发一个应用程序。这个应用程序必须使用像Zebra MZ 220移动打印机这样的移动打印机打印票证。

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. 我一直在谷歌搜索尝试使用Windows Phone 8获取有关打印到蓝牙打印机的信息,但没有太多的信息。

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. 我担心必须在另一个像android这样的移动操作系统上开始新的开发,因为wp8不支持在蓝牙上打印。

Is there any example about it? 有什么关于它的例子吗? Is there any portable printer compatible with Microsoft Windows Phone 8? 有没有与Microsoft Windows Phone 8兼容的便携式打印机?

This code works for me on a Zebra 420 paired with a Nokia 820. 此代码适用于Zebra 420和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. WP8上已经有其他BT-SPP打印机的例子 It should be possible to connect to your "Zebra" bluetooth printer and send it jobs. 应该可以连接到“Zebra”蓝牙打印机并发送作业。 Based on this documentation is supports the BT-SPP (bluetooth serial port portocol) that WP8 supports: 基于此文档 ,支持WP8支持的BT-SPP(蓝牙串行端口协议):

引用

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. SPP只需通过BT发送和接收字节,您需要知道设备所需的特定格式。 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. 例如,在我的Mindwave Headset WP8 BT SDK中,我必须找到该文档该文档具有针对该特定设备的BT-SPP协议。 There seem to be quite a few OSS projects for Zebra printers , so you might want to see if those have those formats. Zebra打印机似乎有很多 OSS项目 ,所以你可能想看看那些是否有那些格式。

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. 我正在开发一款使用蓝牙打印机的Android应用程序(后来的Windows Phone),它非常简单,我发现它可以通过任何具有蓝牙功能的操作系统完成。 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. 就我而言,我正在使用图像并将字节作为字符串发送。

Zebra 为Windows Mobile .NET框架提供了一个API,用于在WinMo .NET中进行打印

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

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