I’ve seen the thread on PDF with Java, but can’t find anything on how to do this with Kotlin.
Is there a method or do I need to use Java?
Render a PDF file using Java on Android
Specifically the step where I have to: declare and assign the name PDF file in my assets folder
PDFView pdfView=findViewById(R.id.pdfv);
pdfView.fromAsset("agl.pdf").load
I get an error regarding PDFView stating: "Classifier PDFView does not have a companion object and thus must be initialized here'
I'm new to Kotlin and can’t for the life of me do this.
Note: Only using Kotlin as trying to migrate my iOS app to Android and as I use Swift was advised that swift to Kotlin conversion was the best way...whether this is I'm not so sure.
full code for my UserGuideActivity.kt
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.github.barteksc.pdfviewer.PDFView
class UserGuideActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_guide)
PDFView pdfView = findViewById(R.id.pdfv)
pdfView.fromAsset("UserGuide.pdf").load()
}
}
Following advice in comments about pasting into Kotlin file and having automatic conversion, I get:
package com.example.foundationdoctorshandbook
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.github.barteksc.pdfviewer.PDFView
class UserGuideActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_user_guide)
val pdfView = findViewById(android.R.id.pdfv)
pdfView.fromAsset("UserGuide.pdf").load()
}
}
Problem here is that PDFView is never used so the id pdfv is not linked