collect_app/src/main/java/org/odk/collect/android/activities/PrintFormInstanceActivity.java
private void createWebPrintJob(WebView webView) {

        // Get a PrintManager instance
        PrintManager printManager = (PrintManager) this
                .getSystemService(Context.PRINT_SERVICE);

        String jobName = getString(R.string.app_name) + " Document";

        // Get a print adapter instance
        PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter(jobName);

        // Set default page size to A4
        PrintAttributes.Builder builder = new PrintAttributes.Builder();
        builder.setMediaSize( PrintAttributes.MediaSize.ISO_A4);

        // Create a print job with name and adapter instance
        PrintJob printJob = printManager.print(jobName, printAdapter, builder.build());


        // Save the job object for later status checking
        // printJobs.add(printJob);
    }
/** Google's WebView print code **/
Google's WebView print code
Google ' s WebView print code
private void createWebPrintJob(WebView webView) {
        PrintManager printManager = (PrintManager) this
                .getSystemService(Context.PRINT_SERVICE);
        String jobName = getString(R.string.app_name) + " Document";
        PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter(jobName);
        PrintAttributes.Builder builder = new PrintAttributes.Builder();
        builder.setMediaSize( PrintAttributes.MediaSize.ISO_A4);
        PrintJob printJob = printManager.print(jobName, printAdapter, builder.build());
    }
private void createWebPrintJob ( WebView webView ) { PrintManager printManager = ( PrintManager ) this . getSystemService ( Context . PRINT_SERVICE ) ; String jobName = getString ( R . string . app_name ) + " Document" ; PrintDocumentAdapter printAdapter = webView . createPrintDocumentAdapter ( jobName ) ; PrintAttributes . Builder builder = new PrintAttributes . Builder ( ) ; builder . setMediaSize ( PrintAttributes . MediaSize . ISO_A4 ) ; PrintJob printJob = printManager . print ( jobName , printAdapter , builder . build ( ) ) ; }
Google's WebView print code
Google ' s WebView print code
// Get a PrintManager instance // Get a print adapter instance // Set default page size to A4 // Create a print job with name and adapter instance // Save the job object for later status checking // printJobs.add(printJob);