PdfViewer

Functions summary

Unit
@Composable
@ExperimentalPdfApi
PdfViewer(
    pdfDocument: PdfDocument?,
    state: PdfViewerState,
    modifier: Modifier,
    isFormFillingEnabled: Boolean,
    isImageSelectionEnabled: Boolean,
    ocrProvider: OcrProvider?,
    minZoom: Float,
    maxZoom: Float,
    verticalAlignment: Int,
    pagesPerRow: Int,
    horizontalPageSpacing: Dp,
    verticalPageSpacing: Dp,
    fastScrollConfig: FastScrollConfiguration,
    contentPadding: PaddingValues,
    appendContextMenuComponents: (PdfSelectionMenuBuilderScope.() -> Unit)?,
    filterContextMenuComponents: ((ContextMenuComponent) -> Boolean)?,
    onFormWidgetInfoUpdated: ((FormEditInfo) -> Unit)?,
    onFirstContentLoad: (() -> Unit)?,
    onUrlLinkClicked: ((Uri) -> Boolean)?
)

A Composable that presents PDF content, provided as PdfDocument

Functions

@Composable
@ExperimentalPdfApi
fun PdfViewer(
    pdfDocument: PdfDocument?,
    state: PdfViewerState,
    modifier: Modifier = Modifier,
    isFormFillingEnabled: Boolean = false,
    isImageSelectionEnabled: Boolean = false,
    ocrProvider: OcrProvider? = null,
    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(),
    contentPadding: PaddingValues = NoPadding,
    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, If no document is provided, the viewer will remain empty

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.

ocrProvider: OcrProvider? = null

an OcrProvider instance to be used for OCR (Optical Character Recognition) in image PDF content. The caller retains ownership of the OcrProvider and is responsible for calling OcrProvider.close when it is no longer needed.

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 scroller's appearance

contentPadding: PaddingValues = NoPadding

a padding around the whole content. This will add padding for the content after it has been clipped, which is not possible via modifier param. Note: The content bleeds into the padded area when the view is scrolled.

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