1 | initial version |
To use PSPDFKit to open a PDF file in Jetpack Compose, you can follow these steps:
implementation "com.pspdfkit:pspdfkit:7.6.0"
val config = PSPDFKit.Configuration.Builder(context)
.licenseKey("YOUR_LICENSE_KEY")
.build()
val fragment = PSPDFKitFragment.newInstance(config, "/sdcard/my-pdf-file.pdf")
@Composable
fun PdfView() {
AndroidView(
factory = { context ->
PSPDFKitFragment.newInstance(config, "/sdcard/my-pdf-file.pdf")
}
)
}
@Composable
fun MyScreen() {
Column {
Text("PDF Viewer")
PdfView()
}
}
And that's it! You should now be able to open and display a PDF file using PSPDFKit in Jetpack Compose.