- Backwards compatible thanks to PdfiumAndroidKt
- Supports PDF annotations
- Supported gestures: pinch to zoom, tap to zoom, scroll
- Scrolling and dragging supports velocity drag
This renderer uses PdfiumAndroidKt and is backwards compatible but app needs to bundle PDFium native libraries.
implementation("io.github.veselyjan92:pdfviewer-pdfium:1.0.5")
val state = rememberPDFViewerPdfiumState(file)
PDFViewer(
state = state,
)
This renderer uses PdfRenderer. There are some limitations such as lack of support for annotated PDFs on Android api levels less than 31. Read more here
implementation("io.github.veselyjan92:pdfviewer:1.0.5")
val state = rememberPDFViewerAndroidState(file)
PDFViewer(
state = state,
)
Put a sample PDF apollo.pdf in the assets folder.
@Composable
@Preview
private fun PdfViewerAndroidRendererPreview() {
val context = LocalContext.current
val file = File.createTempFile("tmp", "pdf", context.cacheDir).apply {
mkdirs()
deleteOnExit()
writeBytes(context.assets.open("apollo.pdf").readBytes())
}
val state = rememberPDFViewerAndroidState(file)
PDFViewer(
state = state,
modifier = Modifier.fillMaxSize()
)
}