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 — 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 rasterizing, with the bitmap ready for export — e.g. via encodeToPng.
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.
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.