How to invoke the PdfActivity share action programmatically
To move the share action out of the main toolbar of PdfActivity, first hide the item with a ToolbarItemsProvider in your activity subclass:
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setToolbarItemsProvider { defaultItems -> defaultItems.filter { it.id != PdfActivity.MENU_OPTION_SHARE } }}Then trigger the same action from your own UI. Dispatching the item’s action to the ToolbarCoordinator runs the SDK’s handler exactly as a tap on the item would. It opens the sharing menu with Open, Print, and Save As…:
nutrientToolbarCoordinator().dispatch(ToolbarAction.ItemClicked(PdfActivity.MENU_OPTION_SHARE))Two narrower entry points skip the menu:
showSaveAsDialog()onPdfActivityandPdfUiFragmentopens the Save As dialog directly.DocumentSharingManager.shareDocument()shares the document through the system share sheet. ASharingOptionsinstance controls the file name, the page range, and whether annotations are flattened.
To add your own entries to the sharing menu instead, see CustomSharingMenuExample in the Catalog app and PdfUi.setSharingActionMenuListener.