Using window.print() or alternative on Android devices Using window.print() or alternative on Android devices google-chrome google-chrome

Using window.print() or alternative on Android devices


It is clearly stated in this Documentation, "The command is supported on iOS, Chrome on Windows and Safari and Chrome on Mac. It is not supported on Android."

Android phones don't have native support for printing yet, so window.print() will not work. Which means you need to use third-party app to do the printing. You could find some alternatives in this article.


I'm working on a simular problem and came up with this solution:

$(document).ready(function($) {  var ua = navigator.userAgent.toLowerCase();  var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");  $('button.print').click(function(e) {    e.preventDefault();    if (isAndroid) {      // https://developers.google.com/cloud-print/docs/gadget      var gadget = new cloudprint.Gadget();      gadget.setPrintDocument("url", $('title').html(), window.location.href, "utf-8");      gadget.openPrintDialog();    } else {      window.print();    }    return false;  });});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><button class="print">Print this page</button>