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 onKPdfViewerState, 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
Page navigation
Zoom
Rendering
Platform integrations
Creating viewer state
In Compose, userememberPdfViewerState to create and remember a state instance tied to the composition lifecycle:
Sharing state across components
Pass the sameviewerState 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
CollectStateFlow properties with collectAsState() to drive your own UI elements: