PdfView

fun PdfView(document: PdfDocument, modifier: Modifier = Modifier, state: PdfViewState = rememberPdfViewState(), pageSpacing: Dp = 12.dp, pagePadding: Dp = 0.dp, pageColor: Color = Color.White, maxRenderDimension: Int = 4096, onPageError: (pageIndex: Int, error: Throwable) -> Unit = { _, _ -> }, onLinkClick: (PdfLink) -> Boolean = { false }, pageBorder: BorderStroke? = BorderStroke(1.dp, Color(0x22000000)), pageLoadingContent: @Composable BoxScope.(pageIndex: Int) -> Unit = {}, pageErrorContent: @Composable BoxScope.(pageIndex: Int, error: Throwable) -> Unit? = null, onUriLinkClick: (uri: String) -> Unit? = DefaultOnUriLinkClick, onLinkError: (pageIndex: Int, link: PdfLink, error: Throwable) -> Unit = { _, _, _ -> }, maxZoom: Float = PdfViewState.DEFAULT_MAX_ZOOM, gestureZoomEnabled: Boolean = true, searchHighlightStyle: PdfSearchHighlightStyle = PdfSearchHighlightStyle.Default)

Displays every page in document as a vertically scrolling Compose view.

The caller retains ownership of document. PdfView closes temporary rendered bitmaps, but never closes the document itself.

onLinkClick runs before the built-in link behavior. Return true to consume the link. Returning false lets PdfView navigate internal destinations. By default, URI links open through the platform URI handler. Pass null to onUriLinkClick to ignore them, or provide a callback to replace the default behavior. Link activation failures are reported through onLinkError, separately from page loading and rendering failures.

Set pageBorder to null to render pages without a border. pageLoadingContent is shown while page information or imagery is loading. pageErrorContent receives the original failure; when it is null, PdfView displays its built-in error message.

Parameters

document

The open PDF document to display. The caller remains responsible for closing it.

modifier

The modifier applied to the PDF viewport.

state

The state that controls scrolling, zoom, and rendered-page caching.

pageSpacing

The vertical space between adjacent pages.

pagePadding

The padding around the page list.

pageColor

The background color shown behind each rendered page.

maxRenderDimension

The maximum width or height, in pixels, of a rendered page bitmap.

onPageError

Called when page information or page rendering fails.

onLinkClick

Called before built-in link handling. Return true to consume the link.

pageBorder

The border drawn around each page, or null for no border.

pageLoadingContent

Content displayed while a page is loading.

pageErrorContent

Content displayed when a page fails to load or render. When null, the built-in error content is used.

onUriLinkClick

Handles URI links. Pass null to ignore URI links.

onLinkError

Called when link activation fails.

maxZoom

The maximum zoom multiplier for gesture-driven and programmatic zoom while this view is bound to state. It must be finite and at least 1f.

gestureZoomEnabled

Whether multi-touch zoom gestures are enabled. Programmatic zoom through state remains available when disabled. Pan deltas are ignored during a multi-touch zoom to avoid competing with scroll.

searchHighlightStyle

Configures normal and selected search-result highlights.