将ZXING生成的条形码/ QR码发送到蓝牙打印机

时间:2017-01-29 07:55:21

标签: xamarin bluetooth zxing android-bluetooth

  1. 有没有办法将Zebra SDK用于任何其他打印机?
  2. 有没有办法将此输出发送到BlueTooth打印机?
  3. 这是一个非常简单的代码:

    MainActivity.cs:

    using System;
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
    using Android.Graphics;
    using ZXing;
    
    namespace QR_Code_Scanner
    {
    [Activity(Label = "QR_Code_Scanner", MainLauncher = true, Icon = 
    "@drawable/icon")]
    public class MainActivity : Activity
    {
    
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
    
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
    
            // Get our button from the layout resource,
            // and attach an event to it
            ImageView view = FindViewById<ImageView> (Resource.Id.qrCodeView);
            Button scannerButton = FindViewById<Button> 
     (Resource.Id.scannerButton);
            view.SetImageBitmap (GetQRCode ());
    
            scannerButton.Click += async (sender, e) => {
                var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
                var result = await scanner.Scan();
    
                //Console.WriteLine(result.Text);
                Toast.MakeText(this, result.Text, ToastLength.Long).Show();
    
    
            };
        }
    
         private Bitmap GetQRCode()
        {
            var writer = new BarcodeWriter 
            {
                Format = BarcodeFormat.QR_CODE,
                Options = new ZXing.Common.EncodingOptions 
                {
                    Height = 600,
                    Width = 600
                }
            };
             return  writer.Write ("LEC-15 8320");
        }
    }
    }
    

1 个答案:

答案 0 :(得分:0)

我想你可以看一下这些文件

Cross platform app development for printing 我从未使用过这个SDK(它很年轻)。

通常你可以直接使用打印机命令。我不记得哪些命令语言使用Zebra,我认为他们使用ESC / PL或ZPL

ZPL programming guide

例如在ZPL中我认为你应该发送^ BC代码为Code128