[英]how android use BlueTooth printer print the WebView content
how to print the HTML using a bluetooth printer with android?Can I print the String="< html > < body >You scored 192 points." 如何在Android上使用蓝牙打印机打印HTML?我可以打印String =“ <html> <body>您得分192分。” into html page?
进入html页面?
There's a quick how-to on the Android Developer site about printing the contents of a WebView: Android Developer网站上有一个关于如何打印WebView内容的快速操作方法:
from https://developer.android.com/training/printing/html-docs.html 来自https://developer.android.com/training/printing/html-docs.html
// Get a PrintManager instance
PrintManager printManager = (PrintManager) getActivity()
.getSystemService(Context.PRINT_SERVICE);
// Get a print adapter instance
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
// Create a print job with name and adapter instance
String jobName = getString(R.string.app_name) + " Document";
PrintJob printJob = printManager.print(jobName, printAdapter,
new PrintAttributes.Builder().build());
You don't even have to display the WebView first - in fact they recommend that you use a dedicated invisible WebView for printing. 您甚至不必首先显示WebView-实际上,他们建议您使用专用的不可见WebView进行打印。
In order to print to a Bluetooth printer though, you'll need to have the print service app for that printer installed, or use a manufacturer-specific SDK - either of which might not exist :( 为了打印到Bluetooth打印机,您需要为该打印机安装打印服务应用程序,或者使用制造商特定的SDK-两者可能都不存在:(
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.