Package-level declarations

Types

Link copied to clipboard
class ComposeCanvas(drawScope: DrawScope, textMeasurer: TextMeasurer, hairlineWidthPx: Float = 1.0f, skipSystemFontText: Boolean = false) : KiteCanvas

KiteCanvas backed by a Compose Multiplatform DrawScope.

Link copied to clipboard
actual object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

expect object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

actual object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

actual object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

actual object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

actual object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

actual object ImageDecoder

Platform-supplied image decoder. KitePDF's core stays pure-Kotlin-stdlib; actual JPEG / PNG / etc. decoding rides on whatever the host platform already provides: Skia on Desktop, the OS framework on Android / iOS, createImageBitmap on JS.

Link copied to clipboard

Wraps the page's canvas to filter ink, inspect glyphs or insert drawing calls during the page paint pass. Return a KiteCanvas delegating unchanged calls to the supplied canvas. It already includes the optional reader theme, so custom colours pass through that theme too; paper and viewer overlays remain outside the decorator.

Link copied to clipboard
sealed interface KiteDocLayout

How KiteDocView lays its pages out and how the user moves between them.

Link copied to clipboard
data class KiteDocViewColors(val pageBackground: Color = Color.White, val viewportBackground: Color = Color.Transparent, val theme: ReaderTheme? = null, val searchHighlight: Color = Color(0x66FFEB3B), val selectionHighlight: Color = Color(0x664285F4), val selectionHandle: Color = Color(0xFF4285F4), val selectionHandlePainter: KiteSelectionHandlePainter? = null)

Colours used by KiteDocView.

Link copied to clipboard
class KiteDocViewState(val document: KiteDocument, initialPage: Int = 0)

Observable state + control surface of a KiteDocView.

Link copied to clipboard
data class KiteHighlight(val hit: KiteSearchHit, val color: Color? = null, val edgeMarker: Boolean = false, val edgeMarkerColor: Color? = null, val edgeMarkerSide: KiteMarkerSide = KiteMarkerSide.End, val id: String? = null)

One entry of KiteDocViewState.highlights: where to paint (hit) plus how to paint it.

Link copied to clipboard
sealed class KiteLinkAction

A tapped link the viewer cannot follow on its own, handed to KiteDocView's onLinkTap.

Link copied to clipboard

Which page margin an edge marker is painted in.

Link copied to clipboard
data class KitePageHit(val pageIndex: Int, val x: Double, val y: Double)

A KiteDocViewState.hitTest result: the page under a viewport point and the point in that page's own space (PDF: user space, y-up from the display box's bottom-left with rotation unfolded; EPUB: the page's document space).

Link copied to clipboard
class KitePageRasterizer(density: Density, layoutDirection: LayoutDirection, textMeasurer: TextMeasurer, maxBitmapPixels: Long)

Imperative page → ImageBitmap pipeline. This is the raster engine behind KiteDocView; it is public so apps with custom viewers (own pagers, thumbnail grids, PNG export jobs) don't have to re-implement the CTM/flip/hairline math themselves.

Link copied to clipboard
sealed interface KiteRenderSpec

How KiteDocView turns pages into pixels. Pick a variant; each carries only the knobs that actually apply to it, so there are no settings that silently do nothing. Defaults to Rasterized via KiteRenderSpec.Default.

Link copied to clipboard
data class KiteScrollPosition(val location: KiteLocation, val offsetPx: Int = 0)

A continuous viewport anchor that a host can persist between reading sessions. location names the leading visible page, and offsetPx counts unzoomed layout pixels scrolled beyond that page's leading edge along the scroll axis. It works for vertical and horizontal continuous layouts, including right-to-left layout direction. It does not save zoom or cross-axis pan.

Link copied to clipboard

Which end of the selection a handle marks, in reading order.

Link copied to clipboard

Draws one selection boundary marker ("thumb") for KiteDocView.

Link copied to clipboard

Default look of KiteSelectionMenu's built-in chrome.

Link copied to clipboard
class KiteSelectionMenuItem(val label: String, val icon: @Composable () -> Unit? = null, val clearsSelection: Boolean = true, val onClick: (KiteTextSelection) -> Unit)

One action in a KiteSelectionMenu: a label, an optional leading icon slot, and what to do with the selected text.

Link copied to clipboard
data class KiteTextSelection(val pageIndex: Int, val start: Int, val end: Int, val text: String, val quads: List<KiteRectangle>)

A finalized or in-progress text selection on one page (cross-page selection is out of scope). start/end are INCLUSIVE flattened char indices into the page's io.github.yuroyami.kitepdf.core.KiteStructuredText reading order; text carries \n/\n\n line/block separators exactly like the extraction text; quads are display-space, one per line touched.

Link copied to clipboard
data class KiteZoomSpec(val pinchEnabled: Boolean = true, val doubleTapEnabled: Boolean = true, val panEnabled: Boolean = true, val minZoom: Float = 1.0f, val maxZoom: Float = 8.0f, val doubleTapZoom: Float = 2.5f, val resetZoomOnPageChange: Boolean = true)

Zoom & pan behaviour for KiteDocView.

Link copied to clipboard
typealias PageHit = KitePageHit
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Encode this ImageBitmap to PNG bytes, the "saveable image" counterpart of KiteDocView's onPageRendered callback. Write the result to a file, share it, upload it; PNG is lossless so the export is pixel-identical to what was on screen.

Link copied to clipboard
fun EpubView(document: EpubDocument, modifier: Modifier = Modifier, page: Int? = null, background: Color = Color.White, theme: ReaderTheme? = null, pageSpacing: Dp = 8.dp, onPageRendered: (pageIndex: Int, image: ImageBitmap) -> Unit? = null, onTap: (Offset) -> Unit? = null, onLinkTap: (PdfAction) -> Boolean? = null)
Link copied to clipboard
fun KiteDocView(document: KiteDocument, modifier: Modifier = Modifier, page: Int? = null, background: Color = Color.White, theme: ReaderTheme? = null, pageSpacing: Dp = 8.dp, selectionEnabled: Boolean = true, onPageRendered: (pageIndex: Int, image: ImageBitmap) -> Unit? = null, onTap: (Offset) -> Unit? = null, onLinkTap: (KiteLinkAction) -> Boolean? = null)

Convenience entry point: remembers its own state internally. Takes any KiteDocument, so a PdfDocument and an io.github.yuroyami.kitepdf.epub.EpubDocument both go here.

fun KiteDocView(state: KiteDocViewState, modifier: Modifier = Modifier, layout: KiteDocLayout = KiteDocLayout.Default, zoomSpec: KiteZoomSpec = KiteZoomSpec(), renderSpec: KiteRenderSpec = KiteRenderSpec.Default, colors: KiteDocViewColors = KiteDocViewColors(), pageSpacing: Dp = 8.dp, userScrollEnabled: Boolean = true, selectionEnabled: Boolean = true, onPageRendered: (pageIndex: Int, image: ImageBitmap) -> Unit? = null, pagePlaceholder: @Composable (pageIndex: Int) -> Unit? = null, chapterPlaceholder: @Composable (chapter: Int) -> Unit? = null, overlay: @Composable BoxScope.(KiteDocViewState) -> Unit? = null, onTap: (Offset) -> Unit? = null, onLinkTap: (KiteLinkAction) -> Boolean? = null, scripts: PdfScriptHandler? = null, onHighlightTap: (KiteHighlight) -> Boolean? = null, onEpubReferenceTap: (EpubLink) -> Boolean? = null)

THE KitePDF viewer composable. It draws a KiteDocument, so a PDF and an EPUB go through the same code path, the same gestures and the same widgets.

Link copied to clipboard
fun KiteNavigationControls(state: KiteDocViewState, modifier: Modifier = Modifier, contentColor: Color = Color.White, containerColor: Color = Color(0xB3222222), textStyle: TextStyle = TextStyle.Default)

Previous / "x of y" / next pill. Buttons auto-disable at the ends.

Link copied to clipboard
fun KiteOutlinePanel(state: KiteDocViewState, modifier: Modifier = Modifier, outline: List<KiteOutlineItem> = state.document.outline, contentPadding: PaddingValues = PaddingValues(8.dp), textStyle: TextStyle = TextStyle(fontSize = 14.sp), textColor: Color = Color(0xFF202124), disabledTextColor: Color = Color(0xFF9AA0A6), currentPageColor: Color = Color(0xFF4A90D9), indent: Dp = 16.dp, onNavigate: (KiteOutlineItem) -> Unit? = null)

A navigation panel over the document's outline (PDF bookmarks / EPUB table of contents): an indented, clickable column of KiteOutlineItems. Clicking an entry scrolls to its target (and calls onNavigate); on a book still paginating this lays out that one chapter rather than the whole book; entries without one (unresolvable destinations, grouping labels) render dimmed and unclickable. Plain foundation styling, like every widget here.

Link copied to clipboard
fun KitePageIndicator(state: KiteDocViewState, modifier: Modifier = Modifier, textStyle: TextStyle = TextStyle.Default, format: (currentPage: Int, pageCount: Int) -> String = { c, t -> "${c + 1} / $t" })

"current / total" page readout. Recomposes as the user scrolls or swipes.

Link copied to clipboard
fun BoxScope.KiteSelectionMenu(state: KiteDocViewState, items: List<KiteSelectionMenuItem>, modifier: Modifier = Modifier, highlightColors: List<Color> = emptyList(), onHighlightColorPicked: (KiteTextSelection, Color) -> Unit? = null, clearSelectionOnColorPick: Boolean = true, alignment: Alignment = Alignment.TopCenter, showWhileSelecting: Boolean = false, containerColor: Color = KiteSelectionMenuDefaults.ContainerColor, contentColor: Color = KiteSelectionMenuDefaults.ContentColor, container: @Composable (selection: KiteTextSelection, content: @Composable () -> Unit) -> Unit? = null, itemContent: @Composable (item: KiteSelectionMenuItem, selection: KiteTextSelection) -> Unit? = null, colorSwatch: @Composable (color: Color, onPick: () -> Unit) -> Unit? = null)

The selection context menu: place it in KiteDocView's overlay slot and it appears whenever text is selected, listing items and, when highlightColors is non-empty, a wrapping row of colour swatches.

Link copied to clipboard
fun KiteThumbnailStrip(state: KiteDocViewState, modifier: Modifier = Modifier, thumbnailHeight: Dp = 72.dp, spacing: Dp = 8.dp, contentPadding: PaddingValues = PaddingValues(8.dp), selectedBorderColor: Color = Color(0xFF4A90D9), pageBackground: Color = Color.White)

Horizontal strip of tappable page thumbnails; the current page is outlined. Tapping a thumbnail animates the KiteDocView sharing this state to that page.

Link copied to clipboard
fun PdfNavigationControls(state: KiteDocViewState, modifier: Modifier = Modifier, contentColor: Color = Color.White, containerColor: Color = Color(0xB3222222), textStyle: TextStyle = TextStyle.Default)
Link copied to clipboard
fun PdfOutlinePanel(state: KiteDocViewState, modifier: Modifier = Modifier, outline: List<KiteOutlineItem> = state.document.outline, contentPadding: PaddingValues = PaddingValues(8.dp), textStyle: TextStyle = TextStyle(fontSize = 14.sp), textColor: Color = Color(0xFF202124), disabledTextColor: Color = Color(0xFF9AA0A6), currentPageColor: Color = Color(0xFF4A90D9), indent: Dp = 16.dp, onNavigate: (KiteOutlineItem) -> Unit? = null)
Link copied to clipboard
fun PdfPageIndicator(state: KiteDocViewState, modifier: Modifier = Modifier, textStyle: TextStyle = TextStyle.Default, format: (currentPage: Int, pageCount: Int) -> String = { c, t -> "${c + 1} / $t" })
Link copied to clipboard
fun BoxScope.PdfSelectionMenu(state: KiteDocViewState, items: List<KiteSelectionMenuItem>, modifier: Modifier = Modifier, highlightColors: List<Color> = emptyList(), onHighlightColorPicked: (KiteTextSelection, Color) -> Unit? = null, clearSelectionOnColorPick: Boolean = true, alignment: Alignment = Alignment.TopCenter, showWhileSelecting: Boolean = false, containerColor: Color = KiteSelectionMenuDefaults.ContainerColor, contentColor: Color = KiteSelectionMenuDefaults.ContentColor, container: @Composable (selection: KiteTextSelection, content: @Composable () -> Unit) -> Unit? = null, itemContent: @Composable (item: KiteSelectionMenuItem, selection: KiteTextSelection) -> Unit? = null, colorSwatch: @Composable (color: Color, onPick: () -> Unit) -> Unit? = null)
Link copied to clipboard
fun PdfThumbnailStrip(state: KiteDocViewState, modifier: Modifier = Modifier, thumbnailHeight: Dp = 72.dp, spacing: Dp = 8.dp, contentPadding: PaddingValues = PaddingValues(8.dp), selectedBorderColor: Color = Color(0xFF4A90D9), pageBackground: Color = Color.White)
Link copied to clipboard
fun PdfView(document: PdfDocument, modifier: Modifier = Modifier, page: Int? = null, background: Color = Color.White, pageSpacing: Dp = 8.dp, selectionEnabled: Boolean = true, onPageRendered: (pageIndex: Int, image: ImageBitmap) -> Unit? = null, onTap: (Offset) -> Unit? = null, onLinkTap: (PdfAction) -> Boolean? = null)
fun PdfView(state: KiteDocViewState, modifier: Modifier = Modifier, layout: KiteDocLayout = KiteDocLayout.Default, zoomSpec: KiteZoomSpec = KiteZoomSpec(), renderSpec: KiteRenderSpec = KiteRenderSpec.Default, colors: KiteDocViewColors = KiteDocViewColors(), pageSpacing: Dp = 8.dp, userScrollEnabled: Boolean = true, selectionEnabled: Boolean = true, onPageRendered: (pageIndex: Int, image: ImageBitmap) -> Unit? = null, pagePlaceholder: @Composable (pageIndex: Int) -> Unit? = null, overlay: @Composable BoxScope.(KiteDocViewState) -> Unit? = null, onTap: (Offset) -> Unit? = null, onLinkTap: (PdfAction) -> Boolean? = null)
Link copied to clipboard
Link copied to clipboard

Remembers a state reopened at a page and continuous scroll offset.

Remembers a KiteDocViewState opened at bookmark, a position saved from an earlier reading session.

Remembers a KiteDocViewState for document. Hoist it to drive a KiteDocView from anywhere: navigation buttons in your top bar, a zoom slider, a HUD overlay. The state object is the single point of control.

Link copied to clipboard

KitePageRasterizer wired to the composition's density, layout direction and font resolver.

rememberKitePageRasterizer with an explicit per-bitmap allocation ceiling.

Link copied to clipboard