PdfView
THE KitePDF viewer composable.
// Simple: whole document, vertical continuous scroll.
PdfView(rememberPdfViewState(doc), Modifier.fillMaxSize())
// Full control: horizontal pager, custom zoom, HUD overlay.
val state = rememberPdfViewState(doc)
PdfView(
state = state,
layout = PdfLayout.Paged(Orientation.Horizontal),
zoomSpec = PdfZoomSpec(maxZoom = 6f),
overlay = { s ->
PdfNavigationControls(s, Modifier.align(Alignment.BottomCenter))
},
)
// …and the same state drives widgets OUTSIDE the viewport too:
PdfPageIndicator(state)By default (PdfRenderSpec.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 re-execute the PDF content stream. Switch to PdfRenderSpec.Vectorized for resolution-independent, bitmap-free drawing. See PdfRenderSpec for the per-mode knobs and PdfZoomSpec for gestures.
Parameters
the hoisted control surface. See rememberPdfViewState.
continuous strip (any orientation), snap pager (any orientation) or a single fixed page. See PdfLayout.
pinch/double-tap/pan behaviour and zoom bounds. Programmatic zoom through PdfViewState.setZoom honours the same bounds, so external controls (sliders, loupes) work with gestures fully disabled.
how pages become pixels: PdfRenderSpec.Rasterized (bitmap-cached, with quality/memory/crisp-zoom/hairline knobs) or PdfRenderSpec.Vectorized (live vector draw). See PdfRenderSpec.
page paper + viewport letterbox colours.
gap between pages (continuous gutter / pager spacing).
gesture scrolling/swiping of the layout itself. Disable to drive paging exclusively through PdfViewState (nav buttons).
fires whenever a page finishes a FRESH rasterization, with the bitmap ready for export, e.g. via encodeToPng. Cache hits from the T-15 bitmap LRU do not re-fire it.
shown in a page's slot until its raster is ready. Defaults to a plain PdfViewColors.pageBackground box.
HUD layer drawn over the viewport; receives state and a BoxScope for alignment. Widgets here float above the pages: PdfNavigationControls, PdfPageIndicator, PdfThumbnailStrip 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 PdfZoomSpec.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 an action the viewer can't perform itself: a URI, 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.
Convenience entry point: remembers its own state internally.
PdfView(document = doc, modifier = Modifier.fillMaxSize()) // whole document
PdfView(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.