'Barteksc pdfviewer not working Android kotlin
Hey I am working on PdfView library. It all working fine. But when I update from 2.8.2 to 3.2.0-beta.1 it stop rendering file in view. But it work in fromAsset() function. I need to update this library because I want to handle click event inside the pdf. Can someone guide me why this is causing issue?. Thanks
PdfViewActivity.kt
class PdfViewActivity : AppCompactActivity() {
internal lateinit var binding: PdfViewLayoutBinding
private val viewModel: PdfViewViewModel by inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = PdfViewLayoutBinding.inflate(layoutInflater)
setContentView(binding.root)
setupView()
}
internal fun setupView() {
binding.pdfView
.fromFile(viewModel.getPdfFile())
.load()
}
}
PdfViewViewModel.kt
class PdfViewViewModel : AndroidViewModel() {
var pdfFilePath = "/data/data/com.example.app.dev/sample.pdf"
fun getPdfFile(): File? {
return if (!pdfFilePath.isNullOrEmpty()) {
File(pdfFilePath)
} else {
null
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
