【问题标题】:Android : Print imageview imageAndroid : 打印 imageview 图像
【发布时间】:2013-12-09 04:15:42
【问题描述】:

我是 android 新手,我正在使用 android 默认打印设置来打印我当前的应用程序和打印 imageview 图像。我正在使用下面的代码来打印图像。但是当我在模拟器上运行时,我得到了带有保存选项而不是打印选项的输出,并且在设备上运行它也不起作用。任何人都可以提出一些想法来做到这一点。

PrintHelper photoPrinter = new PrintHelper(MainActivity.this);
    photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FILL);
    photoPrinter.printBitmap("test.jpg", imgbitmap );

提前致谢。

【问题讨论】:

  • 你有没有发现为什么这在设备上不起作用?我也有同样的问题。

标签: android printing


【解决方案1】:

如果有任何打印应用程序可用,您也可以通过意图进行打印。为此,您可以获取图像视图的绘图缓存并使用意图传递 uri。如下代码。

 Intent printIntent = new Intent(Intent.ACTION_SEND);
            printIntent.setType("image/*");
            printIntent.putExtra(Intent.EXTRA_TITLE,
                    "some cool title for your document");
            Bitmap imageToSave = drawFragment.getDrawView().getWholeView();

            String imgSaved = FileUtil.saveImageInGallery(
                    getApplicationContext(), imageToSave);
            Uri uri = Uri.parse(imgSaved);

            printIntent.putExtra(Intent.EXTRA_STREAM, uri);

            startActivity(printIntent);

【讨论】:

    【解决方案2】:
    PrintHelper printHelper = new PrintHelper(context);
    printHelper.setScaleMode(PrintHelper.SCALE_MODE_FILL);
    printHelper.printBitmap(printJobName, bitmap);
    

    【讨论】:

      猜你喜欢
      • 2011-08-04
      • 1970-01-01
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-09
      • 1970-01-01
      • 2014-12-13
      相关资源
      最近更新 更多