FileDocCategorySizeDatePackage
PrintFileDocumentAdapter.javaAPI DocAndroid 5.1 API5290Thu Mar 12 22:22:10 GMT 2015android.print

PrintFileDocumentAdapter

public class PrintFileDocumentAdapter extends PrintDocumentAdapter
Adapter for printing PDF files. This class could be useful if you want to print a file and intercept when the system is ready spooling the data, so you can delete the file if it is a temporary one. To achieve this one must override {@link #onFinish()} and delete the file yourself.
hide

Fields Summary
private static final String
LOG_TAG
private final android.content.Context
mContext
private final File
mFile
private final PrintDocumentInfo
mDocumentInfo
private WriteFileAsyncTask
mWriteFileAsyncTask
Constructors Summary
public PrintFileDocumentAdapter(android.content.Context context, File file, PrintDocumentInfo documentInfo)
Constructor.

param
context Context for accessing resources.
param
file The PDF file to print.
param
documentInfo The information about the printed file.


                               
        
              
        if (file == null) {
            throw new IllegalArgumentException("File cannot be null!");
        }
        if (documentInfo == null) {
            throw new IllegalArgumentException("documentInfo cannot be null!");
        }
        mContext = context;
        mFile = file;
        mDocumentInfo = documentInfo;
    
Methods Summary
public voidonLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, android.os.CancellationSignal cancellationSignal, LayoutResultCallback callback, android.os.Bundle metadata)

        callback.onLayoutFinished(mDocumentInfo, false);
    
public voidonWrite(PageRange[] pages, android.os.ParcelFileDescriptor destination, android.os.CancellationSignal cancellationSignal, WriteResultCallback callback)

        mWriteFileAsyncTask = new WriteFileAsyncTask(destination, cancellationSignal, callback);
        mWriteFileAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR,
                (Void[]) null);