【问题标题】:How to print directly from iPad without any popup options in cordova print plugin?如何直接从 iPad 打印,而无需在 cordova 打印插件中弹出任何选项?
【发布时间】:2017-04-26 09:32:53
【问题描述】:

我正在使用这个科尔多瓦插件: https://github.com/katzer/cordova-plugin-printer

  $ionicPlatform.ready().then(function () {

    var printerId = $scope.printData.printerUrl;
    alert('print to: ' + printerId);

    cordova.plugins.printer.pick(function(printerId) {
      cordova.plugins.printer.print("<p>TEST PRINT</p>", { printerId: printerId, bounds:[20, 20, 0, 0] });

    });
});

我想知道如何在不弹出任何窗口的情况下直接打印到打印机。

【问题讨论】:

    标签: ios cordova ionic-framework phonegap-plugins


    【解决方案1】:

    使用 ng-cordova 打印机,此代码直接打印到打印机。 确保您有正确的打印机 URL。类似“ipp://192.168.../ipp”

    var htmlContent = "<!DOCTYPE html><html><head><meta charset='UTF-8'><title>Title</title> <link href='css/print.css' rel='stylesheet' /></head><body><div>test print</div></body></html>"
    
          var options = {
              name: 'print-job', // printjob name
              printerId: $scope.PrinterUrl, // network url of the printer to use (iOS only)
              //duplex: false, // default true (double sided) (iOS only)
              landscape: false, // default false (portrait)
              graystyle: true, // prints black and white (default), but true has better performance
              bounds: {left:0, top:0, width:0, height:0}, // size and position of the print view (iPad only)
              hidePaperFormat: true,
              border: false,
              hidePageRange: true
            };
    
          $cordovaPrinter.print(htmlContent, options).then(function(msg){
            console.log('Print Ok: ' + msg);
          });
    

    【讨论】:

      猜你喜欢
      • 2010-11-08
      • 2019-04-09
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 2018-11-11
      • 2021-02-22
      • 1970-01-01
      相关资源
      最近更新 更多