本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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.");
}
}