86.4 Implementing the onLayout() Callback Method
Remaining within the MainActivity.kt file, begin by adding some import directives that will be required by the code in the onLayout() method:
package com.ebookfrenzy.customprint
.
.
import android.print.PrintDocumentInfo
import android.print.pdf.PrintedPdfDocument
import android.graphics.pdf.PdfDocument
class MainActivity : AppCompatActivity() {
.
.
}
Next, modify the MyPrintDocumentAdapter class to declare variables to be used within the onLayout() method:
inner class MyPrintDocumentAdapter(private var context: Context) :
PrintDocumentAdapter() {
private var pageHeight: Int = 0
private var pageWidth: Int = 0
...