Printing WebView contents on a Bluetooth printer

Issue

I’m using following code from developer site to print web-view to Bluetooth printer from android app.

 private void createWebPrintJob(WebView webView) {

    PrintManager printManager  (PrintManager) this
          .getSystemService(Context.PRINT_SERVICE);

    PrintDocumentAdapter printAdapter  
             webView.createPrintDocumentAdapter();

    String jobName  getString(R.string.app_name) + 
                        " Print Test";

    printManager.print(jobName, printAdapter,
           new PrintAttributes.Builder().build());
}

But It loads webview and ask to save as PDF, instead of showing Bluetooth printers available. Even if we search for printers it is searching for long time with no result.

So please suggest me someway to the dynamic HTML content or webview to Bluetooth printer.

Solution

The above code works if you have a supported plugin service available in the playstore. Unfortunately the printer(Intermec 6820 series) doesn’t have any. So I ended up formatting the text using android String.format and printing it out.

Answered By – sravs

Leave a Comment