• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PrintJob类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: printOrCreatePdfFromWebview

import android.print.PrintJob; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@SuppressWarnings("deprecation")
public PrintJob printOrCreatePdfFromWebview(WebView webview, String jobName) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        Context c = webview.getContext();
        PrintDocumentAdapter printAdapter;
        PrintManager printManager = (PrintManager) c.getSystemService(Context.PRINT_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            printAdapter = webview.createPrintDocumentAdapter(jobName);
        } else {
            printAdapter = webview.createPrintDocumentAdapter();
        }
        if (printManager != null) {
            return printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
        }
    } else {
        Log.e(getClass().getName(), "ERROR: Method called on too low Android API version");
    }
    return null;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:21,代码来源:ShareUtilBase.java


示例2: printWebView

import android.print.PrintJob; //导入依赖的package包/类
/**
 * Print the current web site
 */
@RequiresApi(19)
public void printWebView(@Nullable PrintListener listener) {
    PrintManager printManager = (PrintManager) getContext().getSystemService(Context.PRINT_SERVICE);
    PrintDocumentAdapter printAdapter = createPrintDocumentAdapter();
    PrintAttributes.Builder builder = new PrintAttributes.Builder();
    builder.setMediaSize(PrintAttributes.MediaSize.ISO_A4);
    PrintJob printJob = printManager.print(getTitle(), printAdapter, builder.build());
    if (listener!=null) {
        if(printJob.isCompleted()){
            listener.onSuccess();
        } else {
            listener.onFailed();
        }
    }
}
 
开发者ID:vic797,项目名称:prowebview,代码行数:19,代码来源:ProWebView.java


示例3: createWebPrintJob

import android.print.PrintJob; //导入依赖的package包/类
public void createWebPrintJob(WebView webView) {

        // Get a PrintManager instance
        PrintManager printManager = (PrintManager) mContext
                .getSystemService(Context.PRINT_SERVICE);

        // Get a print adapter instance
        PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();

        // Create a print job with name and adapter instance
//        String jobName = getString(R.string.app_name) + " Document";
        String jobName = "QuickFoodsBill";
        PrintJob printJob = printManager.print(jobName, printAdapter,
                new PrintAttributes.Builder().build());

        // Save the job object for later status checking
        mPrintJobs.add(printJob);
    }
 
开发者ID:alseambusher,项目名称:QuickFoods-android,代码行数:19,代码来源:BillPrinterManager.java


示例4: createWebPrintJob

import android.print.PrintJob; //导入依赖的package包/类
private void createWebPrintJob(WebView webView) {

        // Get a PrintManager instance
        PrintManager printManager = (PrintManager) this
                .getSystemService(Context.PRINT_SERVICE);

        // Get a print adapter instance
        PrintDocumentAdapter printAdapter = webView.createPrintDocumentAdapter();

        // Create a print job with name and adapter instance
        String jobName = getString(R.string.app_name) + " Document";
        PrintJob printJob = printManager.print(jobName, printAdapter,
                new PrintAttributes.Builder().build());
    }
 
开发者ID:ashutoshbsathe,项目名称:COEP-Moodle-via-Webview,代码行数:15,代码来源:Moodle.java


示例5: dumpJobStatesForDebug

import android.print.PrintJob; //导入依赖的package包/类
@RemovableInRelease
private void dumpJobStatesForDebug() {
    List<PrintJob> printJobs = mPrintManager.getPrintJobs();
    String[] states = new String[printJobs.size()];

    for (int i = 0; i < printJobs.size(); i++) {
        String stateString;
        switch (printJobs.get(i).getInfo().getState()) {
            case PrintJobInfo.STATE_CREATED:
                stateString = "STATE_CREATED";
                break;
            case PrintJobInfo.STATE_QUEUED:
                stateString = "STATE_QUEUED";
                break;
            case PrintJobInfo.STATE_STARTED:
                stateString = "STATE_STARTED";
                break;
            case PrintJobInfo.STATE_BLOCKED:
                stateString = "STATE_BLOCKED";
                break;
            case PrintJobInfo.STATE_FAILED:
                stateString = "STATE_FAILED";
                break;
            case PrintJobInfo.STATE_COMPLETED:
                stateString = "STATE_COMPLETED";
                break;
            case PrintJobInfo.STATE_CANCELED:
                stateString = "STATE_CANCELED";
                break;
            default:
                stateString = "STATE_UNKNOWN";
                break;
        }
        states[i] = stateString;
    }
    Log.v(TAG, "Initiating new print with states in queue: {%s}", TextUtils.join(", ", states));
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:38,代码来源:PrintManagerDelegateImpl.java


示例6: printNote

import android.print.PrintJob; //导入依赖的package包/类
private void printNote() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        PrintManager printManager = (PrintManager) activity.getSystemService(Context.PRINT_SERVICE);
        String jobName = getString(R.string.app_name) + " Document";
        PrintDocumentAdapter printAdapter = editor.createPrintDocumentAdapter();
        PrintJob printJob = printManager.print(jobName, printAdapter, new PrintAttributes.Builder().build());
    }
}
 
开发者ID:konradrenner,项目名称:kolabnotes-android,代码行数:9,代码来源:DetailFragment.java


示例7: printDocument

import android.print.PrintJob; //导入依赖的package包/类
void printDocument(WebView webView, String title)
{
	if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
	{
		PrintManager printManager = (PrintManager) mContext.getSystemService(Context.PRINT_SERVICE);

		//noinspection deprecation
		PrintDocumentAdapter printDocumentAdapter = webView.createPrintDocumentAdapter();

		if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) printDocumentAdapter = webView.createPrintDocumentAdapter(title);

		if(printManager != null)
		{
			PrintAttributes printAttributes = new PrintAttributes.Builder().build();

			PrintJob printJob = printManager.print(title, printDocumentAdapter, printAttributes);

			List<PrintJob> printJobs = printManager.getPrintJobs();

			printJobs.add(printJob);
		}
	}
	else
	{
		showToast(mContext.getString(R.string.mytools_printing_not_supported), 1);
	}
}
 
开发者ID:olejon,项目名称:mdapp,代码行数:28,代码来源:MyTools.java


示例8: printOrCreatePdfFromWebview

import android.print.PrintJob; //导入依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@SuppressWarnings("deprecation")
public PrintJob printOrCreatePdfFromWebview(WebView webview, Document document) {
    String jobName = String.format("%s (%s)", document.getTitle(), _context.getString(R.string.app_name));
    return super.printOrCreatePdfFromWebview(webview, jobName);
}
 
开发者ID:gsantner,项目名称:markor,代码行数:7,代码来源:ShareUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Buffer类代码示例发布时间:2022-05-22
下一篇:
Java Type类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap