android.print.PrintDocumentInfo Java Examples

The following examples show how to use android.print.PrintDocumentInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IdentityPrintDocumentAdapter.java    From secure-quick-reliable-login with MIT License 6 votes vote down vote up
@Override
public void onLayout(
        PrintAttributes oldAttributes,
        PrintAttributes newAttributes,
        CancellationSignal cancellationSignal,
        LayoutResultCallback callback,
        Bundle metadata
) {
    mPdfDocument = new PrintedPdfDocument(activity, newAttributes);
    if (cancellationSignal.isCanceled() ) {
        callback.onLayoutCancelled();
        return;
    }

    PrintDocumentInfo info = new PrintDocumentInfo
            .Builder("Identity.pdf")
            .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
            .setPageCount(1)
            .build();
    callback.onLayoutFinished(info, true);
}
 
Example #2
Source File: RescueCodePrintDocumentAdapter.java    From secure-quick-reliable-login with MIT License 6 votes vote down vote up
@Override
public void onLayout(
        PrintAttributes oldAttributes,
        PrintAttributes newAttributes,
        CancellationSignal cancellationSignal,
        LayoutResultCallback callback,
        Bundle metadata
) {
    mPdfDocument = new PrintedPdfDocument(activity, newAttributes);
    if (cancellationSignal.isCanceled() ) {
        callback.onLayoutCancelled();
        return;
    }

    PrintDocumentInfo info = new PrintDocumentInfo
            .Builder("RescueCode.pdf")
            .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
            .setPageCount(1)
            .build();
    callback.onLayoutFinished(info, true);
}
 
Example #3
Source File: PrintingControllerImpl.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public void pageCountEstimationDone(final int maxPages) {
    // This method might be called even after onFinish, e.g. as a result of a long page
    // estimation operation.  We make sure that such call has no effect, since the printing
    // dialog has already been dismissed and relevant cleanup has already been done.
    // Also, this ensures that we do not call askUserForSettingsReply twice.
    if (mPrintingState == PRINTING_STATE_FINISHED) return;
    if (maxPages != PrintDocumentInfo.PAGE_COUNT_UNKNOWN) {
        mLastKnownMaxPages = maxPages;
    }
    if (mPrintingState == PRINTING_STATE_STARTED_FROM_ONLAYOUT) {
        PrintDocumentInfo info = new PrintDocumentInfo.Builder(mPrintable.getTitle())
                .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
                .setPageCount(mLastKnownMaxPages)
                .build();
        mOnLayoutCallback.onLayoutFinished(info, mNeedNewPdf);
    } else if (mPrintingState == PRINTING_STATE_STARTED_FROM_ONWRITE) {
        // Chromium PDF generation is started inside onWrite, continue that.
        if (mPrintingContext == null) {
            mOnWriteCallback.onWriteFailed(mErrorMessage);
            resetCallbacks();
            return;
        }
        mPrintingContext.askUserForSettingsReply(true);
    }
}
 
Example #4
Source File: PrintJobProxy.java    From NewXmPluginSDK with Apache License 2.0 5 votes vote down vote up
public PrintDocumentInfo getDocumentInfo() {
    PrintDocument document = printJob.getDocument();
    if (document == null) {
        return null;
    } else {
        return document.getInfo();
    }
}
 
Example #5
Source File: PrintingControllerImpl.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onFinish() {
    mLastKnownMaxPages = PrintDocumentInfo.PAGE_COUNT_UNKNOWN;
    mPages = null;

    if (mPrintingContext != null) {
        if (mPrintingState != PRINTING_STATE_READY) {
            // Note that we are never making an extraneous askUserForSettingsReply call.
            // If we are in the middle of a PDF generation from onLayout or onWrite, it means
            // the state isn't PRINTING_STATE_READY, so we enter here and make this call (no
            // extra). If we complete the PDF generation successfully from onLayout or onWrite,
            // we already make the state PRINTING_STATE_READY and call askUserForSettingsReply
            // inside pdfWritingDone, thus not entering here.  Also, if we get an extra
            // AskUserForSettings call, it's handled inside {@link
            // PrintingContext#pageCountEstimationDone}.
            mPrintingContext.askUserForSettingsReply(false);
        }
        mPrintingContext.updatePrintingContextMap(mFileDescriptor, true);
        mPrintingContext = null;
    }

    if (mContextFromScriptInitiation != null) {
        mContextFromScriptInitiation.showSystemDialogDone();
        mContextFromScriptInitiation = null;
    }

    mPrintingState = PRINTING_STATE_FINISHED;

    closeFileDescriptor(mFileDescriptor);
    mFileDescriptor = -1;

    resetCallbacks();
    // The printmanager contract is that onFinish() is always called as the last
    // callback. We set busy to false here.
    mIsBusy = false;
}
 
Example #6
Source File: PrintDocument.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
PrintDocument(PrintJobId printJobId, IPrintServiceClient printServiceClient,
        PrintDocumentInfo info) {
    mPrintJobId = printJobId;
    mPrintServiceClient = printServiceClient;
    mInfo = info;
}
 
Example #7
Source File: PrintDocumentAdapterWrapper.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {
    mCallback.onLayoutFinished(info, changed);
}
 
Example #8
Source File: PrintDocument.java    From android_9.0.0_r45 with Apache License 2.0 2 votes vote down vote up
/**
 * Gets the {@link PrintDocumentInfo} that describes this document.
 *
 * @return The document info.
 */
public @NonNull PrintDocumentInfo getInfo() {
    PrintService.throwIfNotCalledOnMainThread();
    return mInfo;
}
 
Example #9
Source File: PrintDocumentAdapterWrapper.java    From 365browser with Apache License 2.0 votes vote down vote up
void onLayoutFinished(PrintDocumentInfo info, boolean changed);