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.
KPdfSaveState is a sealed interface that models the full lifecycle of saving the current PDF to a user-chosen location on the device. Collect it from KPdfViewerState.saveState (a StateFlow) to drive progress indicators, confirmation banners, and error handling. Trigger the flow by calling viewerState.requestSave(). The SDK then serialises the document, opens the platform native file-save picker, and progresses through the states below until a terminal state (Success, Cancelled, or Error) is reached. The state resets to Idle at the start of each new save request.
Variants
No save operation is in progress. This is the initial state and the state the SDK returns to after the next
requestSave() call replaces the previous terminal state.The SDK is serialising the current PDF into bytes in preparation for writing. Display a loading indicator while in this state. The platform file picker has not opened yet.
Serialisation is complete and the platform file-save picker is open. The user has not yet chosen a destination.
Unique identifier for this save request. Use it to correlate
AwaitingDestination, Success, and Cancelled events when multiple save requests could be in flight.The file name the SDK pre-filled in the picker, derived from the document title or a default such as
document.pdf.The MIME type proposed to the picker, typically
application/pdf.The user selected a destination and the file was written successfully.
The identifier of the completed save request, matching the
AwaitingDestination.requestId for the same flow.The file name that was used when the file was written.
The MIME type of the saved file.
A platform-specific URI or path string for the saved file, if the platform makes it available.
null on platforms that do not expose the final path.The user dismissed the file-save picker without choosing a destination. No file was written.
The identifier of the cancelled request.
The file name that was proposed to the picker.
The MIME type that was proposed to the picker.
The save flow failed — either during serialisation or after the user chose a destination.
A sealed
KPdfError value describing the failure. Check reason.message for a human-readable description.The file name that was in use when the error occurred, if available.
The MIME type that was in use when the error occurred, if available.
Reacting to save state in Compose
CollectsaveState with collectAsState() and branch on each variant to update your UI. Call requestSave() from a button or toolbar action to start the flow — KPdfViewerToolbar does this automatically when showSave is true.
Notes
KPdfViewerState.saveStateis aStateFlow<KPdfSaveState>, so collecting it is safe on the first frame and never suspends.- The
Exporting→AwaitingDestinationtransition happens on a background dispatcher; do not block the main thread waiting for it.- If you use
rememberPdfViewerState, the native file picker is already wired automatically. You only need to observe the state and react toSuccessorError.
- If you use
requestIdis a monotonically increasingLong. If the user triggers multiple rapid saves, each request receives a distinct identifier so you can safely ignore stale terminal states.