Text-to-speech for our Android viewer
The Android PDF text-to-speech feature is enabled by default. The TextSelectionPopupToolbar that appears when the user selects text offers a speak action, which reads the selection aloud through the device’s text-to-speech engine.
To remove the action, register an OnPreparePopupToolbarListener on the fragment and filter the item out right before the popup is displayed. The text selection popup toolbar guide covers the rest of this technique:
pdfFragment.setOnPreparePopupToolbarListener(object : OnPreparePopupToolbarListener { override fun onPrepareTextSelectionPopupToolbar(toolbar: TextSelectionPopupToolbar) { toolbar.menuItems = toolbar.menuItems.filter { it.id != R.id.pspdf__text_selection_toolbar_item_speak } }})getPdfFragment().setOnPreparePopupToolbarListener(new OnPreparePopupToolbarListener() { @Override public void onPrepareTextSelectionPopupToolbar(@NonNull TextSelectionPopupToolbar toolbar) { final List<PopupToolbarMenuItem> items = new ArrayList<>(toolbar.getMenuItems()); items.removeIf(item -> item.getId() == R.id.pspdf__text_selection_toolbar_item_speak); toolbar.setMenuItems(items); }});