Ionic-native: @ionic-native/printer not working

Created on 21 Apr 2017  路  11Comments  路  Source: ionic-team/ionic-native

I have added the plugin as explained in the documentation. Printer plugin . Also, added the Printer provider in app.module.ts
Now when I call the printer plugin, it does not open the print preview window. The code is as follows:

this.printer.isAvailable().then(function(){
          this.printer.print(content, options).then(function(){
              console.log("Done!");
          }, function(error){
              console.log("Error while printing!");
          });
        }, function(error){
              console.log("Failed.")
        });
need to reproduce printer

Most helpful comment

Hey everyone,

To fix this issue, I uninstalled the current version of the plugin (0.7.3) and installed the latest version (0.7.4). I did so using the following commands:
ionic cordova plugin rm de.appplant.cordova.plugin.printer
ionic cordova plugin add https://github.com/katzer/cordova-plugin-printer.git
After doing this commands are working as expected. According the the repo, 0.7.4 is meant to correct these issues on Android N+, not sure why it hasn't been officially released yet.

All 11 comments

this.printer.isAvailable().then((onsuccess: any) => {

        let options: PrintOptions = {
            name: 'MyDocument',
            printerId: 'printer007',
            duplex: true,
            landscape: true,
            grayscale: true
        };
       this.printer.print('<h1>aaa</h1>',options).then((value: any) => {
                console.log('value:', value);
            }, (error) => {
                console.log('error:', error);
            });

    }, (err) => {
        console.log('err:', err)
    });

[
printer

Same here, using ionic-native version 3.10.3

On the Brwser platform, I am getting error when isAvaliable() is being called:

TypeError: Printer_1.getPlugin(...).check is not a function
    at index.js:68
    at new t (polyfills.js:3)
    at Printer.check (index.js:66)
    at Printer.value [as check] (decorators.js:49)
    at Printer.isAvailable (index.js:58)
    at PrintService.<anonymous> (PrintService.ts:39)

My code is very similar to what @lynzz posted above

My line number 39 is

 isAvailable = await this.printer.isAvailable()

I am also facing the same issue. . If anyone find a breakthrough for this TypeError issue . .Let us Know .Thanks in adavance

Hi everybody, same issue here too :

TypeError: Printer_1.getPlugin(...).check is not a function
    at index.js:68
    at new t (polyfills.js:3)
    at Printer.check (index.js:66)
    at Printer.value [as check] (decorators.js:49)
    at Printer.isAvailable (index.js:58)
    at PrintService.<anonymous> (PrintService.ts:39)

Hey everyone,

To fix this issue, I uninstalled the current version of the plugin (0.7.3) and installed the latest version (0.7.4). I did so using the following commands:
ionic cordova plugin rm de.appplant.cordova.plugin.printer
ionic cordova plugin add https://github.com/katzer/cordova-plugin-printer.git
After doing this commands are working as expected. According the the repo, 0.7.4 is meant to correct these issues on Android N+, not sure why it hasn't been officially released yet.

Somehow the command was not able to install on windows 8 from git. So did,
cordova plugin add https://github.com/katzer/cordova-plugin-printer.git
and
cordova build.
It worked.

Hey Everyone

would this work on android 4.2.2?

ionic cordova plugin add https://github.com/katzer/cordova-plugin-printer.git is not working
but error message is not show and nothing happen.

Same here, using ionic-native version 3.20

Hey, I added the correct npm package cordova-plugin-printer.
If you still get errors like that, it is not a problem with the ionic-native wrapper.

You can specify an network URL in PrintOptions as it is shown in the docs ('printer007'), but it could lead to the "Printing to null" error on iOS.

this.printer.print(content, {printerId: 'networkURL'})

When you add an invalid value there, you'll get the described error "printing to "(null)".
When you don't specify a value at all, you'll be redirected to the default AirPrint view, where you can search for printers. (Same for android).

You can find more options to add in the official docs

Was this page helpful?
0 / 5 - 0 ratings