androidx.pdf.compose

Provides @Composables for presenting PDF content

Interfaces

PdfZoomScrollScope

Scope used for suspending scroll blocks

Classes

FastScrollConfiguration

Value class describing visual customization to the fast scrolling affordance.

PdfSelectionMenuBuilderScope

Scope for building a selection menu in PdfViewer.

PdfViewerState

A state object that can be hoisted to observe and control PdfViewer zoom, scroll, and content position.

Top-level functions summary

Unit
@Composable
PdfViewer(
    pdfDocument: PdfDocument?,
    state: PdfViewerState,
    modifier: Modifier,
    minZoom: Float,
    maxZoom: Float,
    verticalAlignment: Int,
    fastScrollConfig: FastScrollConfiguration,
    appendContextMenuComponents: (PdfSelectionMenuBuilderScope.() -> Unit)?,
    filterContextMenuComponents: ((ContextMenuComponent) -> Boolean)?,
    onUrlLinkClicked: ((Uri) -> Boolean)?
)

A Composable that presents PDF content, provided as PdfDocument

Top-level functions

@Composable
fun PdfViewer(
    pdfDocument: PdfDocument?,
    state: PdfViewerState,
    modifier: Modifier = Modifier,
    minZoom: Float = PdfView.DEFAULT_MIN_ZOOM,
    maxZoom: Float = PdfView.DEFAULT_MAX_ZOOM,
    verticalAlignment: Int = PdfView.VERTICAL_ALIGNMENT_CENTER,
    fastScrollConfig: FastScrollConfiguration = FastScrollConfiguration.withDrawableAndDimensionIds(),
    appendContextMenuComponents: (PdfSelectionMenuBuilderScope.() -> Unit)? = null,
    filterContextMenuComponents: ((ContextMenuComponent) -> Boolean)? = null,
    onUrlLinkClicked: ((Uri) -> Boolean)? = null
): Unit

A Composable that presents PDF content, provided as PdfDocument

Parameters
pdfDocument: PdfDocument?

the PDF content to present

state: PdfViewerState

the state object used to observe and control content position

modifier: Modifier = Modifier

the Modifier to be applied to this PDF viewer

minZoom: Float = PdfView.DEFAULT_MIN_ZOOM

the minimum zoom / scaling factor that can be applied to the PDF viewer

maxZoom: Float = PdfView.DEFAULT_MAX_ZOOM

the maximum zoom / scaling factor that can be applied to the PDF viewer

verticalAlignment: Int = PdfView.VERTICAL_ALIGNMENT_CENTER

the alignment of the top page within the view

fastScrollConfig: FastScrollConfiguration = FastScrollConfiguration.withDrawableAndDimensionIds()

a FastScrollConfiguration instance to customize the fast scoller's appearance

appendContextMenuComponents: (PdfSelectionMenuBuilderScope.() -> Unit)? = null

a callback that can be used to add context menu items.

filterContextMenuComponents: ((ContextMenuComponent) -> Boolean)? = null

a callback that can be used to filter context menu items. This will be executed on the complete list of menu items after appendContextMenuComponents is completed.

onUrlLinkClicked: ((Uri) -> Boolean)? = null

a callback to be invoked when the user taps a URL link in this PDF viewer