当前位置: 首页>>代码示例>>Java>>正文


Java PrintedPdfDocument类代码示例

本文整理汇总了Java中android.print.pdf.PrintedPdfDocument的典型用法代码示例。如果您正苦于以下问题:Java PrintedPdfDocument类的具体用法?Java PrintedPdfDocument怎么用?Java PrintedPdfDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrintedPdfDocument类属于android.print.pdf包,在下文中一共展示了PrintedPdfDocument类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onLayout

import android.print.pdf.PrintedPdfDocument; //导入依赖的package包/类
@Override
public void onLayout(	PrintAttributes oldAttributes,
						PrintAttributes newAttributes,
						CancellationSignal cancellationSignal,
						LayoutResultCallback callback,
						Bundle metadata)
{
	Log.d(TAG, "Creating new PDF");
	pdf = new PrintedPdfDocument(SharePrinterActivity.this, newAttributes);
	if (cancellationSignal.isCanceled())
	{
		callback.onLayoutCancelled();
		return;
	}
	PrintDocumentInfo info = new PrintDocumentInfo
		.Builder("printer_qr_code.pdf")
		.setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
		.setPageCount(1)
		.build();
	callback.onLayoutFinished(info, true);
}
 
开发者ID:pelya,项目名称:android-print-plugin-cups,代码行数:22,代码来源:SharePrinterActivity.java

示例2: onLayout

import android.print.pdf.PrintedPdfDocument; //导入依赖的package包/类
@Override
public void onLayout(PrintAttributes oldAttributes,
        PrintAttributes newAttributes,
        CancellationSignal cancellationSignal,
        LayoutResultCallback callback, Bundle extras) {

    mPdfDocument = new PrintedPdfDocument(mContext, newAttributes);

    if (cancellationSignal.isCanceled()) {
        callback.onLayoutCancelled();
        return;
    }
    int pages = 1;
    // newAttributes.getColorMode();
    // newAttributes.getMediaSize().getHeightMils();
    // newAttributes.getMediaSize().getWidthMils();

    PrintDocumentInfo info = new PrintDocumentInfo.Builder("androids.pdf")
            .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
            .setPageCount(pages).build();
    callback.onLayoutFinished(info, true);
}
 
开发者ID:sys1yagi,项目名称:PrintingFrameworkSample,代码行数:23,代码来源:CustomDocumentPrintAdapter.java

示例3: onLayout

import android.print.pdf.PrintedPdfDocument; //导入依赖的package包/类
@Override
public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, final LayoutResultCallback callback, Bundle extras) {

    // Register a cancellation listener
    cancellationSignal.setOnCancelListener(new CancellationSignal.OnCancelListener() {
        @Override
        public void onCancel() {
            callback.onLayoutCancelled();
        }
    });

    // Prepare the layout.
    int newPageCount;
    // Mils is 1/1000th of an inch. Obviously.
    if(newAttributes.getMediaSize().getHeightMils() < 10000) {
        newPageCount = 2;
    } else {
        newPageCount = 1;
    }

    // Create the PDF document we'll use later
    pdfDocument = new PrintedPdfDocument(context, newAttributes);


    // Has the layout actually changed?
    boolean layoutChanged = newPageCount != pageCount;
    pageCount = newPageCount;

    // Create the doc info to return
    PrintDocumentInfo info = new PrintDocumentInfo
            .Builder("print_output.pdf")
            .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
            .setPageCount(pageCount)
            .build();

    // Not actually going to do anything for now
    callback.onLayoutFinished(info, layoutChanged);
}
 
开发者ID:shinobicontrols,项目名称:bitesize-kitkat,代码行数:39,代码来源:PrintShopPrintDocumentAdapter.java

示例4: onLayout

import android.print.pdf.PrintedPdfDocument; //导入依赖的package包/类
@Override
public void onLayout(PrintAttributes oldAttributes,
		PrintAttributes newAttributes,
		CancellationSignal cancellationSignal,
		LayoutResultCallback callback, Bundle extras) {
	// TODO Auto-generated method stub
	
	document=new PrintedPdfDocument(context, newAttributes);
	
	// Respond to cancellation request
    if (cancellationSignal.isCanceled() ) {
        callback.onLayoutCancelled();
        return;
    }
    
    // Compute the expected number of printed pages
    int pages = 2;

    if (pages > 0) {
        // Return print information to print framework
        PrintDocumentInfo info = new PrintDocumentInfo
                .Builder("print_output.pdf")
                .setContentType(PrintDocumentInfo.CONTENT_TYPE_DOCUMENT)
                .setPageCount(pages)
                .build();
        // Content layout reflow is complete
        callback.onLayoutFinished(info, true);
    } else {
        // Otherwise report an error to the print framework
        callback.onLayoutFailed("Page count calculation failed.");
    }
	
}
 
开发者ID:Defuera,项目名称:cards-app,代码行数:34,代码来源:PrintAdapter.java


注:本文中的android.print.pdf.PrintedPdfDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。