Printing

A page prints as it does in a browser, through Android's print dialog: any installed printer, or Save as PDF. Available from 0.19.0.

window.print()

A page's window.print() opens the system print dialog on the browser's activity: a surface browser's own, or the one given to setDialogActivity for an off-screen browser. The page's @media print styles apply. To decide yourself, set a handler:

browser.setPrintHandler(() -> {
    PrintManager pm = (PrintManager) getSystemService(PRINT_SERVICE);
    pm.print("Receipt", browser.createPrintDocumentAdapter("Receipt"), null);
    return true;   // false: the default dialog
});

From your own UI

Text-selection toolbar

A surface browser shows Android's selection toolbar (copy, paste, share, web search). Add your own actions next to them:

browser.setTextSelectionActionModeCallback(new ActionMode.Callback() {
    public boolean onCreateActionMode(ActionMode mode, Menu menu) {
        menu.add(Menu.NONE, R.id.look_up, Menu.NONE, "Look up");
        return true;
    }
    public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
        if (item.getItemId() != R.id.look_up) return false;
        lookUp(browser.getSelectedText());
        return true;
    }
    public boolean onPrepareActionMode(ActionMode mode, Menu menu) { return false; }
    public void onDestroyActionMode(ActionMode mode) {}
});

Sample: cefrium-sample/printing prints a receipt; its Print button is hidden by the page's print styles.