Xamarin.Android打印问题中的Brother Printer SDK

时间:2016-11-21 07:06:18

标签: xamarin xamarin.android xamarin.forms .so

我正在使用Xamarin.Android处理Brother标签打印机QL-710W。

我创建了一个Android绑定项目,并添加了jar文件和.so文件,如下所示。

我正在使用Visual Studio。

罐子>

  1. BrotherPrintLibrary.jar; BuildAction:EmbeddedJar
  2. MobilePrintLib.jar; BuildAction:ReferenceJar
  3. NativeLibraries> armeabi>

    1. libAndrJFPDFEMB.so; BuildAction:EmbeddedNativeLibrary
    2. libcreatedata.so; BuildAction:EmbeddedNativeLibrary
    3. 附加 ClassTest.cs

      public bool PrintFile(string fileurl, NetPrinter printer)
          {
              Task <bool> printTask = new Task<bool>(() => {
              bool success = true;
                  try
                  {
                      Printer myPrinter = new Printer();
                      PrinterInfo myPrinterInfo = new PrinterInfo();
                      PrinterStatus status = new PrinterStatus();
                      LabelInfo mLabelInfo = new LabelInfo();
      
                      myPrinterInfo.PrinterModel = PrinterInfo.Model.Ql710w;
                      myPrinterInfo.IpAddress = printer.IpAddress;
                      myPrinterInfo.MacAddress = printer.MacAddress;
                      myPrinterInfo.Port = PrinterInfo.PortEnum.Net;
                      myPrinterInfo.PrintMode=PrinterInfo.PrintModeEnum.FitToPage;
                      myPrinterInfo.PaperSize = PrinterInfo.PaperSizeEnum.Custom;
                      myPrinterInfo.Orientation = PrinterInfo.OrientationEnum.Portrait;
                      myPrinterInfo.LabelNameIndex = LabelInfo.QL700.W62.Ordinal();
                      myPrinterInfo.ScaleValue = 1;
      
                      mLabelInfo.LabelNameIndex = LabelInfo.QL700.ValueOf("W62").Ordinal();
                      mLabelInfo.IsAutoCut = true;
                      mLabelInfo.IsEndCut = true;
      
                      myPrinter.SetPrinterInfo(myPrinterInfo);
                      myPrinter.SetLabelInfo(mLabelInfo);
      
                      myPrinter.StartCommunication();
                      status = myPrinter.PrintFile(fileurl);
                      if (status.ErrorCode != PrinterInfo.ErrorCode.ErrorNone)
                          success = false;
                      myPrinter.EndCommunication();
                  }catch(Exception ex)
                  {
                      Console.WriteLine("ERROR : {0}",ex.Message);
                      success = false;
                  }
                  return success;
              });
      
      
              printTask.Start();
      
              var isSuccess = printTask.Result;
      
              return isSuccess;
          }
      

      我正在从网络上成功获得打印机列表。但是当我调用上面的方法时,它会在 myPrinter.SetPrinterInfo(myPrinterInfo); 中获得异常,因为 “无法从loader dalvik.system.PathClassLoader [DexPathList []加载createdata [zip file \“/ data / app / PocAndroidArchieve.PocAndroidArchieve-2.apk \”],nativeLibraryDirectories = [/ data / app-lib / PocAndroidArchieve.PocAndroidArchieve-2,/ vendor / lib,/ system / lib]]]: findLibrary返回null“

      如果有人有想法使用jar和依赖的.so文件,请建议我。

      提前致谢。

0 个答案:

没有答案