Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android : Print html document from WebView

I'v read that the WebView in Android is a simple browser based on webkit and I was thinking that calling window.print() from my html document will be handled by this "mini-browser". But no. After reading many things on that subject, it seems that it's only possible to call a print function from the android app, and not from the html document, and this parti is poorly documented.

Has anyone experienced this before ?

Thanks.

like image 812
martync Avatar asked Mar 17 '23 18:03

martync


1 Answers

Thanks, @martync! Reposting my comment as an answer, as it has turned out to actually answer the question.

The documentation explicitly says "You cannot use JavaScript in a HTML document to trigger printing", and provides an example of how to use the Java API. Chrome for Android (at least Beta) supports window.print().

like image 71
Mikhail Naganov Avatar answered Mar 24 '23 22:03

Mikhail Naganov