KiteDocView
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.
// Simple: whole document, vertical continuous scroll.
KiteDocView(rememberKiteDocViewState(doc), Modifier.fillMaxSize())
// Full control: horizontal pager, custom zoom, HUD overlay.
val state = rememberKiteDocViewState(doc)
KiteDocView(
state = state,
layout = KiteDocLayout.Paged(Orientation.Horizontal),
zoomSpec = KiteZoomSpec(maxZoom = 6f),
overlay = { s ->
KiteNavigationControls(s, Modifier.align(Alignment.BottomCenter))
},
)
// …and the same state drives widgets OUTSIDE the viewport too:
KitePageIndicator(state)By default (KiteRenderSpec.Rasterized) pages are vector-rendered once into an ImageBitmap per (page, size, zoom bucket) and then drawn as plain images, so scrolling, panning and pinching never redraw the page itself. Switch to KiteRenderSpec.Vectorized for resolution-independent, bitmap-free drawing. See KiteRenderSpec for the per-mode knobs and KiteZoomSpec for gestures.
Parameters
the hoisted control surface. See rememberKiteDocViewState.
continuous strip (any orientation), snap pager (any orientation) or a single fixed page. See KiteDocLayout.
pinch/double-tap/pan behaviour and zoom bounds. Programmatic zoom through KiteDocViewState.setZoom honours the same bounds, so external controls (sliders, loupes) work with gestures fully disabled.
how pages become pixels: KiteRenderSpec.Rasterized (bitmap-cached, with quality/memory/crisp-zoom/hairline knobs) or KiteRenderSpec.Vectorized (live vector draw). See KiteRenderSpec.
page paper + viewport letterbox colours.
gap between pages (continuous gutter / pager spacing).
whether the reader may select text at all. The default, true, is the long-press-to-select behaviour with draggable thumbs. False removes the gesture entirely: no long press selects, no wash is painted, no thumbs appear, and a selection already on screen is dropped. Turn it off for a document shown as a picture, a chart, a scan, a trace, where a text selection means nothing and a stray long press only gets in the way of panning.
gesture scrolling/swiping of the layout itself. Disable to drive paging exclusively through KiteDocViewState (nav buttons).
fires whenever a page finishes a FRESH rasterization, with the bitmap ready for export, e.g. via encodeToPng. Cache hits from the page-bitmap LRU do not re-fire it.
shown in a page's slot until its raster is ready. Defaults to a plain KiteDocViewColors.pageBackground box.
shown in the slot a chapter holds while it is still being laid out. Only reflowable EPUB reaches this: a PDF is never mid-layout. Defaults to an empty page-coloured box.
HUD layer drawn over the viewport; receives state and a BoxScope for alignment. Widgets here float above the pages: KiteNavigationControls, KitePageIndicator, KiteThumbnailStrip or anything of your own.
single-tap on the page, reported with the tap position. The tap does not consume pan/swipe, so it coexists with navigation. Typical use is toggling a HUD's visibility. Held back until the double-tap window lapses only when KiteZoomSpec.doubleTapEnabled is on. Taps that land on a link navigate (or go to onLinkTap) instead of reaching this callback.
fires when a tapped link carries something the viewer can't perform itself: a URL, a remote GoTo, a Launch. Return true after handling it (e.g. opening the URL in a browser); false lets the tap fall through to onTap. Internal go-to-page links (PDF destinations, EPUB internal hrefs) never reach this: the viewer scrolls to the target page directly. An EPUB reference to a note goes to onEpubReferenceTap first. See KiteLinkAction for the payload; link.uri covers both formats.
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.
KiteDocView(document = doc, modifier = Modifier.fillMaxSize()) // whole document
KiteDocView(document = doc, page = 0, modifier = Modifier.fillMaxWidth()) // one pageParameters
index of the single page to show, or null (default) for the whole document as a continuous vertical scroll.
colour painted behind page content. Ignored when theme is set (the theme owns the paper colour).
optional reading theme: ReaderTheme.Dark for night mode, ReaderTheme.Sepia, or ReaderTheme.Light/null for the author's colours. Applied at render, so switching is instant (no re-layout).
whether the reader may select text. See the state-based KiteDocView for what turning it off removes.