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.
KPdfExternalOpenState is a sealed interface that models the full lifecycle of sending the current PDF to an installed external application — for example, opening the file in a third-party PDF viewer or annotation tool. Collect it from KPdfViewerState.externalOpenState (a StateFlow) to surface progress and result messages. Trigger the flow by calling viewerState.requestOpenInExternalApp() or viewerState.openInExternalApp(). The state resets to Idle when a new request begins.
Variants
No external-open operation is in progress. This is the initial state and the state after a terminal event has been observed and the next request starts.
The SDK is serialising the current PDF into bytes before dispatching the platform intent or share sheet. Display a loading indicator while in this state. The external app has not been invoked yet.
Serialisation is complete and the platform intent (Android) or share sheet (iOS) has been dispatched. The SDK is waiting for the platform to confirm the handoff.
Unique identifier for this open request. Use it to correlate
AwaitingExternalApp, Success, and Cancelled events across the lifecycle.The file name embedded in the intent or share sheet, such as
document.pdf or a title derived from PDF metadata.The MIME type passed to the intent or share sheet, typically
application/pdf.The platform confirmed that the file was successfully handed off to an external app.
The identifier of the completed request, matching
AwaitingExternalApp.requestId.The file name that was used in the handoff.
The MIME type that was used in the handoff.
A platform-specific URI or path for the temporary file created during the handoff, if the platform makes it available.
null on platforms that do not expose the path.The user dismissed the share sheet or app chooser without selecting a target. No external app received the file.
The identifier of the cancelled request.
The file name that was proposed during the flow.
The MIME type that was proposed during the flow.
The external-open flow failed — either during byte serialisation or during the platform handoff.
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, or
null if the error happened before a file name was determined.The MIME type that was in use when the error occurred, or
null if the error happened before a MIME type was determined.Reacting to external open state in Compose
CollectexternalOpenState and branch on each variant to update your UI. Call requestOpenInExternalApp() — optionally with a suggestedFileName — to start the flow.
Notes
KPdfViewerState.externalOpenStateis aStateFlow<KPdfExternalOpenState>, so it always has a current value and collecting it never suspends on the first frame.requestOpenInExternalApp(suggestedFileName)lets you override the default file name embedded in the intent or share sheet. UseopenInExternalApp()to rely on the SDK-inferred name.- If you use
rememberPdfViewerState, the platform effect that handles the intent result is already wired automatically. You do not need to register any platform callbacks yourself.
- If you use
requestIdis a monotonically increasingLong. If the user triggers the flow multiple times in quick succession, each request receives a distinct identifier so stale terminal states can be safely ignored.KPdfExternalOpenStatemirrors the shape ofKPdfSaveState. The key difference is thatKPdfSaveStatewrites a persistent file chosen by the user, whileKPdfExternalOpenStatehands a temporary file to another app and does not guarantee persistence.