Skip to main content
KPdfFactory is the entry point to the KPDF SDK outside of Compose. It exposes a single static method, create(), that returns a KPdf facade. From the facade you call viewerState() to produce a KPdfViewerState — the same interface used internally by rememberPdfViewerState. Use this path when you need to manage viewer state in a ViewModel, a non-Compose screen, or any other context where Compose lifecycle hooks are not available.
If you are building a Compose Multiplatform UI, prefer rememberPdfViewerState from the kpdf-compose module. It wires up the platform save, open, and external-app effects automatically and ties the viewer state lifetime to the composition. Use KPdfFactory only when you have a concrete reason to manage the lifecycle yourself.

KPdfFactory.create

Returns a platform-specific implementation of the KPdf facade. KPdfFactory is an expect object, so the actual implementation is resolved per platform at compile time.

KPdf.viewerState

Creates a KPdfViewerState for the given source and configuration. You own the state’s lifetime — call close() when the viewer is no longer needed to release cached pages and coroutine work.
KPdfSource
required
The PDF source to load. See KPdfSource for the available variants.
KPdfViewerConfig
default:"KPdfViewerConfig.builder().build()"
The viewer configuration. Defaults to a config with all options at their default values. See KPdfViewerConfig for the full list of options.
Returns KPdfViewerState.

Usage