phonegap-plugin-barcodescanner,使用离子键入PDF417条形码 [英] phonegap-plugin-barcodescanner, type PDF417 bar-codes using ionic

查看:241
本文介绍了phonegap-plugin-barcodescanner,使用离子键入PDF417条形码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Ionic开发相当新,到目前为止还没有遇到太多问题。但是,我仍然试图让PDF417类型的条形码进行扫描(使用phonegap-plugin-barcodescanner),尽管文档建议通过格式选项中的PDF_417参数来支持它们。注意:扫描适用于其他代码,如QR_CODE,EAN_13 - 所以代码大多是正确的。我不认为正在处理错误函数后的选项列表。

I am fairly new to Ionic development and thus far has not run into too many problems. However, I am stuck on trying to get PDF417 type bar-codes to scan (using phonegap-plugin-barcodescanner), despite the documentation suggesting that they are supported via pass the "PDF_417" parameter in the "formats" option. Note: the scanning works on other codes such as QR_CODE, EAN_13 - So the code is mostly right. I don't think that the options list after the error function is being processed.

  $cordovaBarcodeScanner.scan().then(function(imageData) {

    $scope.si_data_display = imageData.text;
    console.log("app.js :: .controller - MainCtrl :: scan_barcode :: text : " + imageData.text);
    console.log("app.js :: .controller - MainCtrl :: scan_barcode :: format : " + imageData.format);
    console.log("app.js :: .controller - MainCtrl :: scan_barcode :: cancelled  : " + imageData.cancelled);

  }, function(error) {
    //TODO: better error handling...
    alert("Error with BarcodeScanner" + error);
  },
  { //I DONT THINK THIS IS WORKING!
    "preferFrontCamera" : true, // iOS and Android
    "showFlipCameraButton" : true, // iOS and Android
    "prompt" : "zzzzzzzzzzzz", // supported on Android only
    "formats" : "PDF_417", // default: all but PDF_417 and RSS_EXPANDED
  });

我们将非常感谢您提供任何帮助,建议或指示。

Any help, suggestion and or pointers will be gratefully received.

提前谢谢,
Harold Clements

Thank you in advance, Harold Clements

推荐答案

是的,你写的代码写得不好,你在$ cordovaBarcodeScanner.scan()函数中有一个错误,因为它是一个promise,因此它从 .them 方法返回两个callbackFuntion

Yes, you have badly written the code, you have an error in the $cordovaBarcodeScanner.scan() funtion, because it is a promise, therefore it returns two callbackFuntion from .them method

q.resolve(result);

q.resolve(result);

q.reject(err);

q.reject(err);

$ CordovaBarcodeScanner ia a返回两个函数的工厂

$CordovaBarcodeScanner ia a factory that returns two functiosns

带输入参数的函数

scan:function(config) {

和带有两个输入参数的第二个

and the secondone with two input arguments

编码:函数(类型) ,数据){}

bouth是promise functios

bouth are promise functios

所以正确的方法来制作请求是:

so the correct way to make the request is:

document.addEventListener("deviceready", function () {
$scope.scan= function () {

  $cordovaBarcodeScanner
    .scan({ //I KNOW THIS IS GOOD!
           "preferFrontCamera" : true, // iOS and Android
           "showFlipCameraButton" : true, // iOS and Android
           "prompt" : "zzzzzzzzzzzz", // supported on Android only
           "formats" : "PDF_417"  //NO ',' in the last element
          })
    .then(function (imageData) {
      $scope.si_data_display = imageData.text;
      alert(JSON.stringify(imageData));
    }, function (error) {
      $scope.result=" :( intentalo de nuevo. Ocurrio un Error"
      alert(Error);
    });
}
  /*
    try to use, but inject in your controller
    $ionicPlatform.ready(function() {
      $cordovaBarcodeScanner.scan().then(success, error);
    });
  */

你的html

<button class="button" ng-click="scan()">Escanear</button>

查看ios库,它只包含以下内容格式,因此它不适用于iOS。如果你找到一些使用IONIC在ios中扫描PDF417的方法,你可以分享它!

Reviewing the ios library, it only contains the following types of formats, so it does not work for iOS. If you find some method to scan PDF417 in ios using IONIC, you can share it!

typedef enum BarcodeFormat {
    BarcodeFormat_None = 0,
    BarcodeFormat_QR_CODE,
    BarcodeFormat_DATA_MATRIX,
    BarcodeFormat_UPC_E,
    BarcodeFormat_UPC_A,
    BarcodeFormat_EAN_8,
    BarcodeFormat_EAN_13,
    BarcodeFormat_CODE_128,
    BarcodeFormat_CODE_39,
    BarcodeFormat_ITF
} BarcodeFormat;

我希望它对每个人都有用

I hope it will be useful for everyone

这篇关于phonegap-plugin-barcodescanner,使用离子键入PDF417条形码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆