rememberPdfViewerState, and drop KPdfViewer into your layout. The steps below walk through each piece in order.
1
Choose a KPdfSource
KPdfSource describes where the PDF comes from. Pick the variant that matches your data.2
Create a KPdfViewerConfig with the builder
KPdfViewerConfig controls runtime behavior — zoom limits, gesture toggles, and cache sizes. Build it once inside a remember block so the reference stays stable.3
Call rememberPdfViewerState
rememberPdfViewerState creates a KPdfViewerState, opens the document, and binds platform save/open effects for you. Call it at the top of your composable.source and config. Passing a new config object on every recomposition recreates the state and resets all transient flows, including openDocumentState and saveState.4
Add KPdfViewer to your layout
Place For a production screen that also includes a toolbar and thumbnail strip, use the complete layout below.
KPdfViewer anywhere in your composable tree. It reads the active page and zoom level directly from KPdfViewerState.Keep
source and config stable. If you construct KPdfViewerConfig inline — outside a remember block — Compose recreates it on every recomposition. This causes rememberPdfViewerState to produce a new state instance, which resets openDocumentState, saveState, and other transient flows back to their initial values.