List of usage examples for android.print PrintManager print
public @NonNull PrintJob print(@NonNull String printJobName, @NonNull PrintDocumentAdapter documentAdapter,
@Nullable PrintAttributes attributes)
From source file:net.gsantner.opoc.util.ShareUtil.java
/** * Print a {@link WebView}'s contents, also allows to create a PDF * * @param webview WebView//from w w w . j a v a 2s . 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; }