Skip to main content
KPdfViewerState is the single controller for one PDF viewer instance. It owns the document load pipeline, page navigation, zoom level, and all platform-integration flows. Every KPDF component — KPdfViewer, KPdfViewerToolbar, and KPdfThumbnailStrip — reads from the same state instance, so the entire UI stays in sync automatically without any extra wiring on your part.

Unidirectional data flow

KPDF follows a strict unidirectional pattern: your UI calls an action on KPdfViewerState, the state processes the request internally, and the result surfaces through one of the observable StateFlow properties. Your composables collect those flows and rebuild in response. You never write directly to the state fields.

Observable properties

Actions

Document management

Zoom

Rendering

Platform integrations

Creating viewer state

In Compose, use rememberPdfViewerState to create and remember a state instance tied to the composition lifecycle:
If you manage lifecycle yourself outside of Compose, create state through the core facade:

Sharing state across components

Pass the same viewerState instance to every KPDF component. All three components read and react to the same flows, so navigation, zoom, and load state stay synchronized without any extra code:

Collecting state in your UI

Collect StateFlow properties with collectAsState() to drive your own UI elements: