List of usage examples for android.webkit WebView createPrintDocumentAdapter
public PrintDocumentAdapter createPrintDocumentAdapter(String documentName)
From source file:net.gsantner.opoc.util.ShareUtil.java
/** * Print a {@link WebView}'s contents, also allows to create a PDF * * @param webview WebView/* w w w. j a va 2 s . c o m*/ * @param jobName Name of the job (affects PDF name too) * @return {{@link PrintJob}} or null */ @RequiresApi(api = Build.VERSION_CODES.KITKAT) @SuppressWarnings("deprecation") public PrintJob print(WebView webview, String jobName) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { PrintDocumentAdapter printAdapter; PrintManager printManager = (PrintManager) webview.getContext().getSystemService(Context.PRINT_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { printAdapter = webview.createPrintDocumentAdapter(jobName); } else { printAdapter = webview.createPrintDocumentAdapter(); } if (printManager != null) { return printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build()); } } else { Log.e(getClass().getName(), "ERROR: Method called on too low Android API version"); } return null; }