This library wraps libpdfium (the Chromium PDF engine). The pre-compiled pdfium files are taken from here and bundled into this library.
- Android
- JVM Desktop
- Linux x64, ARM64
- Windows X64
- MacOS X64, ARM64
- iOS (untested)
- x64 (simulator)
- arm64
- arm64Simulator
implementation("com.dshatz.pdfmp:pdfmp-compose:1.0.6")pdfmp = { module = "com.dshatz.pdfmp:pdfmp-compose", version = "1.0.6" } val state = rememberPdfState(PdfSource.PdfBytes(byteArray))val state = rememberPdfState(PdfSource.PdfPath(Path("~/Download/sample.pdf"))You can use this helper.
val bytes: PdfBytes? by asyncPdfResource {
Res.readBytes("files/doc.pdf")
}@Composable
fun ShowDoc(state: PdfState) {
PdfView(state, Modifier.fillMaxSize())
}| Feature | Supported | Notes |
|---|---|---|
| Loading from bytes | ✅ | |
| Loading from path | ✅ | May not work on Android, depending on permissions and path. Please report. |
| Loading from compose resources | ❌ | Does not work directly because native code does not have access to it. See above for how to do it. |
| Zooming and scrolling | ✅ | Loading the high-res image is debounced by 100ms. On desktop, horizontal scrolling can only be done with Shift+Vertical scroll. |
| Filtering pages | ✅ | Pass page range to rememberPdfState |