Skip to main content
KPDF renders PDF documents through a small set of composables that share a single state holder. To display a PDF you choose a source, build a viewer configuration, create the state with 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.
Pass this value down to your composable as a stable parameter so the SDK does not reload the document on every recomposition.
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.
The state is keyed on 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 KPdfViewer anywhere in your composable tree. It reads the active page and zoom level directly from KPdfViewerState.
For a production screen that also includes a toolbar and thumbnail strip, use the complete layout below.
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.