PdfViewState

class PdfViewState(val document: <Error class: unknown class>, initialPage: Int = 0)

Observable state + control surface of a PdfView.

Everything a navigation/zoom widget needs lives here, so widgets are just composables that take a PdfViewState — place them inside the viewport (via PdfView's overlay slot), next to it, or anywhere else in your tree.

Reads (currentPage, zoom, panOffset…) are snapshot-state backed and recompose their readers automatically. Navigation suspends until finished; calls made before the state is attached to a composed PdfView are remembered and applied on attach.

Constructors

Link copied to clipboard
constructor(document: <Error class: unknown class>, initialPage: Int = 0)

Properties

Link copied to clipboard

The page the viewport currently rests on: the snapped page in paged mode, the page nearest the viewport centre in continuous mode.

Link copied to clipboard
val document: <Error class: unknown class>
Link copied to clipboard

True once zoomed in beyond the minimum (with a small epsilon).

Link copied to clipboard
Link copied to clipboard

Pan translation in viewport px, applied after zoom around the viewport centre.

Link copied to clipboard
var zoom: Float

Current zoom factor. 1 = fit. Bounded by PdfZoomSpec.minZoom/maxZoom.

Functions

Link copied to clipboard
suspend fun animateScrollToPage(page: Int)

Animates to page (coerced into range).

Link copied to clipboard
suspend fun animateZoomTo(target: Float, focal: Offset = Offset.Unspecified, animationSpec: AnimationSpec<Float> = spring())

Animates zoom to target (clamped), keeping focal stationary throughout.

Link copied to clipboard
suspend fun nextPage()
Link copied to clipboard
fun panBy(delta: Offset): Offset

Pans by delta (viewport px), clamped to the zoomed content bounds. Returns the portion actually consumed — the gesture layer hands the remainder back to the underlying scroll container.

Link copied to clipboard
suspend fun previousPage()
Link copied to clipboard
fun resetZoom()

Snaps back to the minimum zoom and recentres.

Link copied to clipboard
suspend fun scrollToPage(page: Int)

Jumps to page (coerced into range) without animation.

Link copied to clipboard
fun setZoom(zoom: Float, focal: Offset = Offset.Unspecified)

Sets zoom immediately, clamped to the active PdfZoomSpec range.