Print online/offline with Third party apps

Plugin to print both online/offline for Cordova 3.x.x
Pankaj Nirwan0.6.0dev0
platforms: ios,android
$ cordova plugin add nirwan.cordova.plugin.printer

Cordova Printer-Plugin

A print plugin to print a file from android/ios cordova app using third party apps. It can print both in online/offline mode.

Modified from this plugin

Supported Platforms

  • iOS (Print from iOS devices to AirPrint compatible printers or other printers using third party apps via wifi)
    See Drawing and Printing Guide for iOS for detailed informations and screenshots.

  • Android (Print through 3rd party printing apps)

Adding the Plugin to your project

Through the Command-line Interface:

cordova plugin add
cordova build

## Removing the Plugin from your project
Through the [Command-line Interface](

cordova plugin rm nirwan.cordova.plugin.printer

Release Notes

Version 0.1.0 (02.09.2014)

  • Based on the Print plugin made by KAtzer

Using the plugin

The plugin creates the object window.plugin.printer


Get all available printing apps on Android

The callback function will be called with a second argument which is an array, indicating which printer apps are available for printing.

    function (isAvailable, installedAppIds) {
        alert('The following print apps are installed on your device: ' + installedAppIds.join(', '));


You need to download/save html using fileTransfer plugin Make sure you use it after deviceReady event is called.

** Below example uses print share app for printing files.

    var pdfHTML = document.getElementById('ELEMENT_TO_PRINT').innerHTML;
    var headstr = "<html><head><title></title></head><body>";
    var footstr = "</body>";

    var name = "downloaded_file.html";

    var filename = "cdvfile://localhost/persistent/" + name;

    var fileTransfer = new FileTransfer();
        encodeURI('data:text/html;charset=utf-8,' + headstr+pdfHTML+footstr),

                function (isAvailable, installedAppIds) {

                    var isPrintShareInstalled = false;

                    installedAppIds.forEach(function(entry) {

                        if(entry == 'com.dynamixsoftware.printershare') {
                            isPrintShareInstalled = true;

                    if(isPrintShareInstalled) { //Going to send file for printing

                        var page = "<HTML>hi</HTML>";
                        window.plugin.printer.print(page, { 'appId': 'com.dynamixsoftware.printershare','filename': name ,'mimeType': 'text/html'});
                    } else {
                            alert(null, "Please install PrinterShare app <br> from Google PlayStore for printing.");
        function(error) {
            alert("download error source " + error.source);
            alert("download error target " +;
            alert("upload error code: " + error.code);


This software is released under the Apache 2.0 License.