Android webview print


I have created an app that is a webview that opens a web page made in PHP in android as if it were an application, it works perfectly but the problem is that the buttons do not print they work, you give them and they do not do anything and if you go by Google chrome in android they work totally, I do not know if in a webview you can not or you need to import something or create some objteto to be able to print.

The code would be:

import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {

    WebView myWebView = (WebView) findViewById(;
    myWebView.loadUrl("la url");
    myWebView.setWebViewClient(new MyWebViewClient());
    WebSettings webSettings = myWebView.getSettings();

private class MyWebViewClient extends WebViewClient {


public boolean onKeyDown(int keyCode, KeyEvent event) {
    WebView mWebView;
    mWebView = (WebView) findViewById(;
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if (mWebView.canGoBack()) {
                } else {
                return true;
    return super.onKeyDown(keyCode, event);

asked by Luis Alfonso Z 01.03.2017 в 16:10

1 answer


The documentation limitations WebView when printing documents:

  • You can not add headers or footers, including numbers from page, to the document.
  • The printing options of the HTML document do not include the possibility of printing page ranges, for example: Page 2 to 4 of an HTML document of 10 is not supported pages.
  • A WebView instance can only process a job from printing at the same time.
  • An HTML document containing CSS printing attributes, such as properties in landscape mode.
  • You can not use JavaScript in an HTML document to activate printing.

In the same documentation you will see how to print from Android. You can do it with a button from your app.

answered by 01.03.2017 в 16:21