KPDF is a Kotlin Multiplatform PDF library that brings a full-featured PDF viewer to Android and iOS Compose Multiplatform apps. You add two Gradle dependencies, point the SDK at a PDF source, and get rendering, caching, zoom, swipe navigation, save/export, and connected toolbar and thumbnail views — all driven by a singleDocumentation Index
Fetch the complete documentation index at: https://mahmoud-b28887f9.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
KPdfViewerState.
Two modules, one viewer
KPDF ships as two independent modules that work together:kpdf-core— The shared PDF engine. Handles source loading, page rendering, RAM and disk caching, navigation, zoom, save/export, external-open, and device file picker state. This is the module you depend on from non-UI code.kpdf-compose— Compose Multiplatform UI components and platform integrations. ProvidesKPdfViewer,KPdfViewerToolbar,KPdfThumbnailStrip, andrememberPdfViewerState, as well as the platform-specific save and open flow bindings for Android and iOS.
kpdf-core alone is enough if you only need the engine APIs — for example, to render pages to bitmaps outside a Compose surface.
Supported platforms
KPDF targets Android and iOS via Kotlin Multiplatform. You write your viewer screen once in shared Compose Multiplatform code and it runs on both platforms.PDF sources
Tell KPDF where your PDF comes from by creating aKPdfSource:
KPdfSource.Url— Loads a PDF over HTTPS. Accepts custom request headers for authenticated endpoints.KPdfSource.Bytes— Takes aByteArrayyou have already loaded.KPdfSource.Base64— Accepts a raw Base64 string or adata:application/pdf;base64,...data URL.
Key features
Quick start
Display your first PDF in under five minutes with a minimal end-to-end working example.
Installation
Add
kpdf-core and kpdf-compose to your Gradle build and get up and running.PDF sources
Load from HTTPS URLs with custom headers, raw byte arrays, or Base64 strings including data URLs.
Viewer state
Control navigation, zoom, save, export, and device file picking through a single
KPdfViewerState.What the SDK handles for you
- RAM and disk page caching — Configurable cache sizes keep scrolling smooth and allow offline reopening of previously loaded remote documents.
- Configurable preloading — The viewer renders nearby pages in the background so swiping feels instant.
- Zoom — Pinch-to-zoom and double-tap zoom with a configurable zoom range and double-tap zoom level.
- Save and export —
requestSave()launches the platform file picker.exportPdf()returns raw bytes for custom share flows. - Open from device —
requestOpenFromDevice()triggers the platform document picker and returns the selected file as a newKPdfSource. - Open in external app —
openInExternalApp()hands the current PDF to any installed app that can open PDFs. - Connected views —
KPdfViewerToolbarandKPdfThumbnailStripshare the sameKPdfViewerStateas the main viewer with no extra wiring.