Android:从 WebView 打印 html 文档 [英] Android : Print html document from WebView

查看:147
本文介绍了Android:从 WebView 打印 html 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到 Android 中的 WebView 是一个基于 webkit 的简单浏览器,我认为从我的 html 文档调用 window.print() 将由这个迷你浏览器"处理.但不是.在阅读了有关该主题的许多内容后,似乎只能从 android 应用程序中调用打印函数,而不能从 html 文档中调用,并且此部分的文档很差.

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 ?

谢谢.

推荐答案

谢谢,@martync!重新发布我的评论作为答案,因为它实际上回答了问题.

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

文档明确指出您不能使用 JavaScript在 HTML 文档中触发打印",并提供了如何使用 Java API 的示例.Android 版 Chrome(至少是 Beta 版)支持 window.print().

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().

这篇关于Android:从 WebView 打印 html 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆