首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何直接从iPad打印没有任何弹出式选项的科多瓦打印插件?

如何直接从iPad打印没有任何弹出式选项的科多瓦打印插件?
EN

Stack Overflow用户
提问于 2016-12-11 10:36:01
回答 1查看 855关注 0票数 1

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

代码语言:javascript
复制
  $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] });

    });
});

我想知道如何直接打印到打印机没有任何弹出。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-13 08:52:42

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

代码语言:javascript
复制
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);
      });
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41085248

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档