> ## Documentation Index
> Fetch the complete documentation index at: https://mahmoud-b28887f9.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# What is KPDF? PDF viewing for Compose Multiplatform

> Learn what KPDF is, how its two modules fit together, which platforms it targets, and what PDF sources and features it provides out of the box.

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 single `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. Provides `KPdfViewer`, `KPdfViewerToolbar`, `KPdfThumbnailStrip`, and `rememberPdfViewerState`, as well as the platform-specific save and open flow bindings for Android and iOS.

Most apps add both modules. `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 a `KPdfSource`:

* `KPdfSource.Url` — Loads a PDF over HTTPS. Accepts custom request headers for authenticated endpoints.
* `KPdfSource.Bytes` — Takes a `ByteArray` you have already loaded.
* `KPdfSource.Base64` — Accepts a raw Base64 string or a `data:application/pdf;base64,...` data URL.

```kotlin theme={null}
// Remote PDF with an auth header
val urlSource = KPdfSource.Url(
    url = "https://example.com/document.pdf",
    headers = mapOf("Authorization" to "Bearer token")
)

// Bytes you loaded yourself
val bytesSource = KPdfSource.Bytes(pdfBytes)

// Base64-encoded content
val base64Source = KPdfSource.Base64(base64String)
```

## Key features

<CardGroup cols={2}>
  <Card title="Quick start" icon="rocket" href="/quickstart">
    Display your first PDF in under five minutes with a minimal end-to-end working example.
  </Card>

  <Card title="Installation" icon="download" href="/installation">
    Add `kpdf-core` and `kpdf-compose` to your Gradle build and get up and running.
  </Card>

  <Card title="PDF sources" icon="file-pdf" href="/concepts/pdf-sources">
    Load from HTTPS URLs with custom headers, raw byte arrays, or Base64 strings including data URLs.
  </Card>

  <Card title="Viewer state" icon="sliders" href="/concepts/viewer-state">
    Control navigation, zoom, save, export, and device file picking through a single `KPdfViewerState`.
  </Card>
</CardGroup>

### 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 new `KPdfSource`.
* **Open in external app** — `openInExternalApp()` hands the current PDF to any installed app that can open PDFs.
* **Connected views** — `KPdfViewerToolbar` and `KPdfThumbnailStrip` share the same `KPdfViewerState` as the main viewer with no extra wiring.
