Can we take a print from Web View?
android, printing
Solution
Try below code
public void createWebPagePrint(WebView webView) {
/*if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT)
return;*/
PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();
String jobName = getString(R.string.webapp_name) + " Document";
PrintAttributes.Builder builder = new PrintAttributes.Builder();
builder.setMediaSize(PrintAttributes.MediaSize.ISO_A5);
PrintJob printJob = printManager.print(jobName, printAdapter, builder.build());
if(printJob.isCompleted()){
Toast.makeText(getApplicationContext(), R.string.print_complete, Toast.LENGTH_LONG).show();
}
else if(printJob.isFailed()){
Toast.makeText(getApplicationContext(), R.string.print_failed, Toast.LENGTH_LONG).show();
}
// Save the job object for later status checking
}
Problem
My simple question is Can we Print the page from Web View through WIFI printing? I have made one page and displayed in Web View so, can i print that page? In emulator it doesn't get any options for that, But in android wifi support phone have the print option. Please help.