Example usage for android.print PrintDocumentAdapter onWrite

List of usage examples for android.print PrintDocumentAdapter onWrite

Introduction

In this page you can find the example usage for android.print PrintDocumentAdapter onWrite.

Prototype

public abstract void onWrite(PageRange[] pages, ParcelFileDescriptor destination,
        CancellationSignal cancellationSignal, WriteResultCallback callback);

Source Link

Document

Called when specific pages of the content should be written in the form of a PDF file to the given file descriptor.

Usage

From source file:android.webkit.cts.WebViewTest.java

private void savePrintedPage(final PrintDocumentAdapter adapter, final ParcelFileDescriptor descriptor,
        final FutureTask<Boolean> result) {
    adapter.onWrite(new PageRange[] { PageRange.ALL_PAGES }, descriptor, new CancellationSignal(),
            new WriteResultCallback() {
                @Override/*  ww  w  . j a v  a2 s.co m*/
                public void onWriteFinished(PageRange[] pages) {
                    try {
                        descriptor.close();
                        result.run();
                    } catch (IOException ex) {
                        fail("Failed file operation: " + ex.toString());
                    }
                }
            });
}