Pearl
Pearl

Reputation: 121

Android : Print imageview image

I'm new to android, i'm doing my current app with print imageview image by using android default print settings. I'm using below code to print image. but while i'm running on emulator, i got output with save options not print option, and also running on device its not working.Can any one please suggest some ideas to do this.

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

Thanks in advance.

Upvotes: 2

Views: 2652

Answers (2)

AnkitRox
AnkitRox

Reputation: 544

PrintHelper printHelper = new PrintHelper(context);
printHelper.setScaleMode(PrintHelper.SCALE_MODE_FILL);
printHelper.printBitmap(printJobName, bitmap);

Upvotes: 0

Manmohan Badaya
Manmohan Badaya

Reputation: 2336

you can print via intent also if any printing app is available.For this purpose u can get drawing cache of imageview and pass the uri using intent.piece of code for that as follows.

 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);

Upvotes: 1

Related Questions