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,
    isFormFillingEnabled: Boolean,
    isImageSelectionEnabled: Boolean,
    minZoom: Float,
    maxZoom: Float,
    verticalAlignment: Int,
    pagesPerRow: Int,
    horizontalPageSpacing: Dp,
    verticalPageSpacing: Dp,
    fastScrollConfig: FastScrollConfiguration,
    appendContextMenuComponents: (PdfSelectionMenuBuilderScope.() -> Unit)?,
    filterContextMenuComponents: ((ContextMenuComponent) -> Boolean)?,
    onFormWidgetInfoUpdated: ((FormEditInfo) -> Unit)?,
    onFirstContentLoad: (() -> Unit)?,
    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,
    isFormFillingEnabled: Boolean = false,
    isImageSelectionEnabled: Boolean = false,
    minZoom: Float = PdfView.MIN_PERMISSIBLE_ZOOM,
    maxZoom: Float = PdfView.MAX_PERMISSIBLE_ZOOM,
    verticalAlignment: Int = PdfView.VERTICAL_ALIGNMENT_CENTER,
    pagesPerRow: Int = PdfView.SINGLE_PAGE,
    horizontalPageSpacing: Dp = 8.dp,
    verticalPageSpacing: Dp = 8.dp,
    fastScrollConfig: FastScrollConfiguration = FastScrollConfiguration.withDrawableAndDimensionIds(),
    appendContextMenuComponents: (PdfSelectionMenuBuilderScope.() -> Unit)? = null,
    filterContextMenuComponents: ((ContextMenuComponent) -> Boolean)? = null,
    onFormWidgetInfoUpdated: ((FormEditInfo) -> Unit)? = null,
    onFirstContentLoad: (() -> Unit)? = 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

isFormFillingEnabled: Boolean = false

boolean flag to enable / disable the form-filling feature surface.

isImageSelectionEnabled: Boolean = false

boolean flag to enable / disable the image-selection feature surface.

minZoom: Float = PdfView.MIN_PERMISSIBLE_ZOOM

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

maxZoom: Float = PdfView.MAX_PERMISSIBLE_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

pagesPerRow: Int = PdfView.SINGLE_PAGE

The number of pages to display in a single row.

horizontalPageSpacing: Dp = 8.dp

The spacing between horizontally adjacent pages.

verticalPageSpacing: Dp = 8.dp

The spacing between vertically adjacent pages.

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.

onFormWidgetInfoUpdated: ((FormEditInfo) -> Unit)? = null

a callback to be invoked when a form widget is updated due to a user interaction. @see PdfView.OnFormWidgetInfoUpdatedListener

onFirstContentLoad: (() -> Unit)? = null

a callback that is invoked when the document's content is first loaded It resets and trigger again if a new document is loaded or if the underlying view is recreated.

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

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