Skip to content

marat101/PDF-Viewer

Repository files navigation

Android PDF-Viewer

Library for displaying PDF documents on Android. There are basic gestures for scrolling and zooming without loss of quality due to rendering fragments of pages that are visible on the screen. There are also horizontal and vertical layouts.

Preview

Preview Preview

Integration

Add to build.gradle:

implementation("io.github.marat101:pdf-viewer:1.0.0-alpha")

Using

@Composable
fun Example(
    modifier: Modifier = Modifier,
    uri: Uri
) {
    val state = rememberReaderLayoutState(
        minZoom = 0.3f,
        maxZoom = 10f,
        uri = uri
    )
    ReaderLayout(
        modifier = modifier
            .fillMaxSize()
            .clipToBounds(),
        layoutState = state,
    ) {}
}

Scroll to page by index

state.positionsState.scrollToPage(pageIndex)

Change layout orientation

state.positionsState.setOrientation(newOrientation)