DocumentState

A state object that can be hoisted to control and observe properties of the com.pspdfkit.jetpack.compose.views.DocumentView. Create instances of this object using rememberDocumentState.

Parameters

configuration

The PdfActivityConfiguration used for this state.

Properties

Link copied to clipboard
val activeViewState: StateFlow<PdfActivityMenuConfiguration.ActiveView>

Tracks which view (thumbnail grid, outline, search) is currently active so com.pspdfkit.jetpack.compose.components.MainToolbar can reflect the correct toolbar button state.

Link copied to clipboard

Provides ability to perform specific tasks in Document.

Link copied to clipboard
val searchViewShown: StateFlow<Boolean>

True while the search view is visible.

Link copied to clipboard

Keep track of whether a full screen view is shown that is not the document view so we can handle the main toolbar clipping

Functions

Link copied to clipboard

Reverts back to viewer from any other State.

Link copied to clipboard

Returns the height (in pixels) of the contextual toolbar, as measured by the SDK layout. Pass this value to setContentViewTopPadding when overlay views (thumbnail grid, outline) are shown, so their content starts exactly below the contextual toolbar.

Link copied to clipboard

Provides the current configuration of the document.

Link copied to clipboard

Provides the document source of the PDF file.

Link copied to clipboard
abstract fun getTitle(): String?

Provides the title of the document.

Link copied to clipboard

Provides the SavedData bundle from the document.

Link copied to clipboard

Handles a back press with the same layered logic as the regular SDK: dismisses the contextual toolbar first if one is shown; otherwise closes the active overlay view (thumbnail grid, outline, etc.).

Link copied to clipboard

Checks if viewer is visible or not. Default value is true

Link copied to clipboard
open override fun onHide(view: View)

Called whenever a PSPDFKit view has been hidden.

Link copied to clipboard
open override fun onShow(view: View)

Called whenever a PSPDFKit view has become visible.

Link copied to clipboard

Sets the top padding (in pixels) of the sibling content view that holds overlay views such as the thumbnail grid. After the first call the automatic Java-side adjustments triggered by contextual toolbar lifecycle events are suppressed, so Compose can own this value without racing against native view code.

Link copied to clipboard
fun setCustomPdfSource(source: DocumentSource? = null)

Sets the custom source for the PDF file. if you pass null in the source param, it will refresh the document by using same source.

Link copied to clipboard

Set the ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener to listen to the lifecycle of the contextual toolbar. Can be implemented in a LaunchedScope to handle the lifecycle of the contextual toolbar, i.e. LaunchedEffect(Unit) { documentState.setOnContextualToolbarLifecycleListener(object : ToolbarCoordinatorLayout.OnContextualToolbarLifecycleListener { override fun onPrepareContextualToolbar(toolbar: ContextualToolbar<*>) { if (toolbar is AnnotationToolbar) { // Register grouping rule to tell toolbar how to group menu items. toolbar.setMenuItemGroupingRule(object : PresetMenuItemGroupingRule(context) { override fun getGroupPreset(capacity: Int, itemsCount: Int) = AnnotationCreationToolbarItemPresets.FOUR_ITEMS_GROUPING; }) } } }) }

Link copied to clipboard
fun setViewState(bundle: Bundle? = null)

Set the SavedData bundle to the document.

Link copied to clipboard
fun toggleView(option: Int)

Toggles the view based on the provided MENU_OPTIONS in com.pspdfkit.ui.PdfActivity.

Link copied to clipboard

Updated the configuration of the document.