Documentation Index
Fetch the complete documentation index at: https://mahmoud-b28887f9.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
KPdfOpenDocumentState is a sealed interface that models the full lifecycle of letting a user pick a PDF from their device storage. Collect it from KPdfViewerState.openDocumentState (a StateFlow) and, on Success, pass the returned KPdfSource directly to viewerState.open() to load the chosen file. Trigger the picker by calling viewerState.requestOpenFromDevice(). The state resets to Idle when a new request is initiated.
Variants
No picker session is in progress. This is the initial state and the state after a terminal event (
Success, Cancelled, or Error) has been handled and the next request starts.The platform file picker is open and waiting for the user to select a file.
Unique identifier for this open request. Use it to correlate picker events when your UI logic needs to distinguish between multiple requests.
The MIME type filter list passed to the platform picker, typically
["application/pdf"]. The picker shows only files matching these types.The user selected a file and the SDK has wrapped it in a
KPdfSource ready for opening.A
KPdfSource instance representing the chosen file. Pass this value to viewerState.open(source) to replace the current document.The user dismissed the picker without selecting a file. The current document remains open and unchanged.
The picker session failed or the SDK was unable to create a
KPdfSource from the selected file.A sealed
KPdfError value describing the failure. Inspect reason.message to get a human-readable explanation.Handling a successful picker result in Compose
Use aLaunchedEffect keyed on openDocumentState to call viewerState.open() as soon as the user’s selection arrives. Pair it with a Button that calls requestOpenFromDevice() to launch the picker.
Notes
KPdfViewerState.openDocumentStateis aStateFlow<KPdfOpenDocumentState>, so it is safe to collect from any composable without suspension on the first frame.- If you use
rememberPdfViewerState, the native file-picker result callback is already wired automatically. You do not need to register any platform callbacks yourself.
- If you use
- If
openDocumentStatenever advances pastIdleafter callingrequestOpenFromDevice(), the most common cause is an unstableKPdfViewerConfigbeing rebuilt on every recomposition, which recreates theKPdfViewerStateand clears the in-flight request. Wrap your config in a top-levelrememberblock as shown in therememberPdfViewerStatereference. - After calling
viewerState.open(selectedSource),loadStatetransitions throughLoading→Ready(orError). You can observe both flows simultaneously.