![](/img/trans.png)
[英]How to push print to bluetooth thermal printer from android webview?
[英]how android use BlueTooth printer print the WebView content
如何在Android上使用藍牙打印機打印HTML?我可以打印String =“ <html> <body>您得分192分。” 進入html頁面?
Android Developer網站上有一個關於如何打印WebView內容的快速操作方法:
來自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());
您甚至不必首先顯示WebView-實際上,他們建議您使用專用的不可見WebView進行打印。
為了打印到Bluetooth打印機,您需要為該打印機安裝打印服務應用程序,或者使用制造商特定的SDK-兩者可能都不存在:(
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.