Cordova打印插件只搜索打印机(在同一网络中有启用wifi的打印机),不打印或不给出任何错误



我正在构建一个Cordova应用程序,它应该允许我们从手机上打印。

我正在关注这个插件

我已经直接在设备上添加了打印代码,所以在设备上我可以选择另存为pdf并搜索打印机,直到这里一切都很好我在app.js 中的代码

var printer = angular.module('starter', ['ionic','ngCordova'])
printer.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    cordova.plugins.printer.isAvailable(
    //Check whether the printer is available or not.
    function (isAvailable) {
         //Enter the page location.
         alert("printer is available")
         var page = location.href;
         cordova.plugins.printer.print(page, 'Document.html', function () {
         alert('printing finished or canceled')
});
    }
); 

因此,上面的代码打开对话框,在这里选择打印机,甚至会提醒消息打印机可用。

主要问题是,当我选择搜索打印机时,它会连续搜索打印机,但直到15分钟才回复,没有超时。我有一台通过局域网连接的无线打印机。

我只是想知道,在打印机上有什么特定的设置可以从android打印吗?

任何形式的建议和帮助都将不胜感激。

这是我使用打印机的代码。请确保您的手机上安装了任何打印机服务。cordova插件将调用该打印机服务,打印机服务将处理打印作业,而不是插件。

angular.module('app.services')
.factory('printService', function() {
    return {
        print: function(printingContent){
            var receipt ='<html>Hello</html>';
            cordova.plugins.printer.check(function (avail, count) {
                if(avail == true){
                    cordova.plugins.printer.pick(function (uri) {
                        //alert("Printer pick: " + uri);
                        cordova.plugins.printer.print(receipt, { duplex: 'long' }, function (res) {
                            alert(res ? 'Printing Done' : 'Printing Canceled');
                        });
                    });
                }                       
                else
                    alert('No printer service found');
            });
        }
    }
})

最新更新