Using window.print() or alternative on Android devices

window.print callback
window.print safari
window print not working
window.print in typescript
window.print set scale
javascript window.print fit to page
android print from webview
window open print

On Android devices (I have tested Nexus 5, Nexus 10, Galaxy S4 and Galaxy Tab 3), the window.print() command in JavaScript doesn't do anything. As far as I can tell it doesn't even register an error.

I know for a fact that most if not all of these browsers can print because you can use mobile Chrome's menu to choose "print".

Why doesn't window.print() trigger the behavior you would expect (opening the clients print menu)? And is there an Android alternative to window.print()?

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.

how to print with android device, In Windows pc it work but in android device it doesn't work. In. I found javascript - Using window.print() or alternative on Android devices  On samsung tab E no browser supports the window.print() I need to print on the client's printer without dialogue. How can i achieve this? Using cpgadget will open more than a confirmation window. Any alternatives?

Use Google Cloud Print (GCP) - there is no app required. The user must have set up a printer via GCP though.

This example uses GCP gadget

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Print</title>
    </head>
    <body>
        <div>
            <p>On android devices (I have tested Nexus 5, Nexus 10, Galaxy S4 and Galaxy Tab 3) the window.print() command in javascript doesn't do anything, as far as I can tell it doesn't even register an error.</p>
            <p>I know for a fact that most if not all of these browsers can print because you can use mobile chromes menu to choose "print".  My questions is, why doesn't window.print() trigger the behavior you would expect (opening the clients print menu).
            And is there an android alternative to window.print()?</p>
        </div>

        <div id="gcpPrint"></div>

        <script src="https://www.google.com/cloudprint/client/cpgadget.js">
        </script>

        <script>
            var gadget = new cloudprint.Gadget();
            gadget.setPrintButton(cloudprint.Gadget.createDefaultPrintButton("gcpPrint"));
            gadget.setPrintDocument("text/html", "Print", document.documentElement.innerHTML);
        </script>
    </body>
</html>

Window.print(), However in more recent versions of Safari, it may return immediately. Syntax. window.print(). Specification. Specification, Status, Comment. HTML  Printing from an Android smartphone is pretty easy but getting started with it can be a little confusing. So, as always, we have got you covered. Here are the different ways through which you can go ahead and start printing from your Android device: Print Any Document From Your Android Device (2020) 1. Google Cloud Print

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>

[Solved] Window.print() is not working in Android mobile browsers , The function window.print() will work if you are using iOS 4.2 or later because that version adds AirPrint support. Android phones don't seem to  1. Plasma Mobile. Plasma Mobile is the most competent Android alternative that you can look up to right now. This open source operating system uses the power of Kubuntu and uses the multiplatform toolkit Qt. Plasma Mobile OS is currently under development, and it can be used on devices like Nexus 5X.

I think, direct print() method is disabled on devices by default. I not saw so many phones or other Android devices with printer, however by USB it should be possible of course.

Instead, recommended is saving content/page as pdf and print it via some cloud print service.

window.print on Google android phones and tablets, $('#print').click(function($) { window.print(); }); The above is **working fine** in all browsers on PC and in smartphones as well **except Google  Everything You Need to Know About Printing From Your Android Phone or Tablet Cameron Summerson @Summerson Updated July 12, 2018, 12:49pm EDT If you’re an Android newcomer, printing probably seems like a no brainer: click a menu, tap a command.

At this moment, window.print() functionality works perfectly on my Android 5.0.1 device with both, Chrome and the default browser.

Using window.print() or alternative on Android devices, On Android devices (I have tested Nexus 5, Nexus 10, Galaxy S4 and Galaxy Tab 3), the window.print() command in JavaScript doesn't do  LuneOS is an open-source mobile OS based on Linux kernel. It may not be a feature-rich alternative to Android (of course!). However, it is the successor to Palm/WebOS. The last release was at the end of 2018. Since then, there have been no updates to the project so far.

window.print() on android, On edge the function works but with dialogue box. On samsung tab E no browser supports the window.print() I need to print Any alternatives? The Android operating system is designed for use in mobile devices, but not all Android devices are mobile phones. The majority of Android devices on the market now are cell phones, but that’s starting to change. Android tablets are becoming increasingly popular, thanks in part to devices such as the 5-inch Dell Streak and the …

How can I print from Android phone through Google Chrome , Yes it should work with Google Cloud Print. From: https://support.google.com/​cloudprint/answer/1686197?rd=1. Log in to your user account on the Windows,  window.print() or window.focus(); window.print() WITH brackets and case sensitive Other than that I do not understand what you mean by "SmartNavigation set to off" "and the page is using a command button for formatting reasons." <form> <input type="button" onClick="window.focus(); window.print()" value="print"></form>

T179529 [Spike] Can we detect browsers where the window.print , Tested on a simulator and with real devices (Pixel w/ Android 8.0 and Nexus 4 w/​Android 5.1.1):. Firefox. Running window.print() throws a 

Comments
  • You need an app to print from an android: play.google.com/store/apps/…
  • yea i installed google cloud print app, when i click the google cloud print button, the dialog box will open and i choose printer then click the print nothing happen. now what should i do?
  • yea i installed google cloud print app, when i click the google cloud print button, the dialog box will open and i choose printer then click the print nothing happen. now what should i do?
  • This is a nice solution, actually more or less what I went with in the end, but my main concern was that I can do the equivilent of File -> Print on my android device (Menu button -> Print) but I can not trigger this with the semi standard window.print() function
  • I could not find the Print command on Chrome android. I can find share ... > Printer.
  • I have not been able to find the mobile character string in any user agent character string so far. Also, the trouble is that sometimes the web browser on the mobile electronic device may emulate the desktop mode, so the android character string does not show up. I could not test with the Google Chrome web browser because it did not seem to work properly. The android character string did show up on the mobile electronic device while using the Firefox web browser and the web Browser web browser made by Litter Penguin.
  • Like I said, chrome for android has a "print" option in its menu. This has to be somehow accessible from javascript and as for converting to PDF could you possible elaborate on that.
  • That's true. But this option is more for cloud print or "print to file" like a pdf or eps where "direct" print can be disabled. Here I found answer stackoverflow.com/questions/9268840/…, can be many reasons why it not working in most of browsers on mobile devices, but in fact, it is just not implemented or disabled. Instead you can still print with share options or save as pdf etc
  • I tried with andriod 7. window.print() does nothing. silently ignored.
  • Firefox on android still doesn't support it though.