1

我正在尝试使用此https://github.com/phonegap-build/BarcodeScanner存储库扫描 pdf417 条码。我的主要目的是扫描美国驾照并获取其全部细节,但它总是显示错误的结果和不同的格式UPC_E, EAN_8 即使我扫描 pdf417 格式的条形码。我也添加了格式过滤器,但它不起作用。有尝试过与此相关的事情的人吗?

cordova.plugins.barcodeScanner.scan(
      function (result) {
          alert("We got a barcode\n" +
                "Result: " + result.text + "\n" +
                "Format: " + result.format + "\n" +
                "Cancelled: " + result.cancelled);
      }, 
      function (error) {
          alert("Scanning failed: " + error);
      }
   );
4

1 回答 1

1

默认情况下,条形码扫描仪插件不会扫描 PDF417,除非您将其添加到插件设置中。

您已链接到https://github.com/phonegap-build/BarcodeScanner,这是一个 4 年前的分支,来自一个不再受维护的插件,它缺乏完整的文档。在我个人看来,它和 Windows 98 一样过时了。

正如您在较新的phonegap-plugin-barcodescanner中看到的那样,如果您想阅读这些代码,则必须将PDF417添加到列表中。formats

{
    preferFrontCamera : true, // iOS and Android
    showFlipCameraButton : true, // iOS and Android
    showTorchButton : true, // iOS and Android
    torchOn: true, // Android, launch with the torch switched on (if available)
    saveHistory: true, // Android, save scan history (default false)
    prompt : "Place a barcode inside the scan area", // Android
    resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500

    /* Add here PDF_417 to support it */
    formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED

    orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
    disableAnimations : true, // iOS
    disableSuccessBeep: false // iOS and Android
    disableSuccessBeep: false // iOS and Android
}

我强烈建议尽可能只使用官方的、最新的插件,如果某些东西没有按预期工作,请在问题部分报告它,而不是转移到较旧的分支。

Android 6.0 改变了权限系统,之前的大部分插件现在都已经过时了。

于 2018-04-25T16:18:55.673 回答