78.4 Implementing the onLayout() Callback Method
Remaining within the MainActivity.java 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;
public class MainActivity extends AppCompatActivity {
.
.
}
Next, modify the MyPrintDocumentAdapter class to declare variables to be used within the onLayout() method:
public static class MyPrintDocumentAdapter extends PrintDocumentAdapter
{
Context context;
int pageHeight;
int pageWidth;
PdfDocument myPdfDocument;
int totalpages = 4;
.
.
}
Note that...