简体   繁体   English

android如何使用蓝牙打印机打印WebView内容

[英]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.

相关问题 如何从android webview推送打印到蓝牙热敏打印机? - How to push print to bluetooth thermal printer from android webview? 如何使用手机默认打印机功能在Xamarin Android中打印从WebView打开的PDF内容 - How to use phone default printer function to print the content of PDF opened from WebView in Xamarin Android 如何在从Android到蓝牙的收据打印机的一行上打印空间或左右对齐内容? - How To Print Spaces Or Left And Right Align Content On One Line From Android To Receipt Printer Over Bluetooth? 在Android中使用蓝牙打印机打印内容 - Printing content with Bluetooth printer in Android 如何在 Android 上的蓝牙打印机中打印 ñ 等特殊字符? - How to print special characters like ñ in Bluetooth Printer on Android? 如何将字符串转换为图像并在Android的蓝牙打印机中打印该图像 - How to convert a string into Image and print that image in a bluetooth printer in Android 如何从Android手机向Bluetooth打印机打印带有文本的图像? - How to print image with text from android phone to Bluetooth printer.? 如何在 Android 中的蓝牙打印机上打印图像? - How can I print an image on a Bluetooth printer in Android? 如何将数据从Android Tablet打印到蓝牙打印机 - How to print data from Android Tablet to a Bluetooth printer 如何从android web浏览器打印到蓝牙热敏打印机? - How to print from android web browser to Bluetooth thermal printer?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM