Skip to main content
KPdfViewerConfig controls runtime behavior for a single KPDF viewer instance: how the user interacts with pages through gestures, how aggressively the SDK caches rendered pages in RAM and on disk, and how many pages to preload in the background. Build a config once, hold it stable in a remember block, and pass it to rememberPdfViewerState.

Builder options

Enable or disable pinch-to-zoom and double-tap zoom on the page surface.
Allow horizontal swipe gestures to navigate between pages when the viewer is at its base zoom level. Disable this if you want to control navigation exclusively through buttons or your own gesture recognizers.
Set the minimum and maximum zoom factors for pinch and double-tap zoom. minZoom must be greater than 0 and maxZoom must be greater than or equal to minZoom.
Set the zoom level applied when the user double-taps a page. The SDK clamps this value to the configured zoom range at build time. Must be greater than 0.
Set the maximum number of rendered page bitmaps held in RAM for this viewer. Larger values make page turns smoother at the cost of memory. Pass 0 to disable the in-memory cache entirely.
Set the maximum number of rendered pages persisted to disk. Disk caching lets the viewer restore pages quickly after they are evicted from RAM. Pass 0 to disable disk caching.
Set how many pages adjacent to the current page the SDK renders in the background. For example, a value of 2 prerenders 2 pages ahead and 2 behind. Pass 0 to disable background preloading.

Using the builder

Call KPdfViewerConfig.builder(), chain the options you want to override, then call build():

Using the DSL

The pdfViewerConfig {} extension is a Kotlin-idiomatic alternative to the builder. It accepts the same Builder receiver, so every option works identically:

Passing config to the viewer

Do not build KPdfViewerConfig inline on every recomposition. rememberPdfViewerState keys on the config reference: if you pass a freshly constructed object each time, it creates a new viewer state instance on every frame and resets transient flows such as openDocumentState, saveState, and externalOpenState.

Default values at a glance