PrintHelper
class PrintHelper
Helper for printing bitmaps.
Summary
Nested types |
|---|
interface PrintHelper.OnPrintFinishCallbackCallback for observing when a print operation is completed. |
Constants |
|
|---|---|
const Int |
COLOR_MODE_COLOR = 2this is a color image (default) |
const Int |
this is a black and white image |
const Int |
Print the image in landscape orientation (default). |
const Int |
Print the image in portrait orientation. |
const Int |
SCALE_MODE_FILL = 2image will fill the paper and be cropped (default) |
const Int |
SCALE_MODE_FIT = 1image will be scaled but leave white space |
Public constructors |
|---|
PrintHelper(context: Context)Constructs the PrintHelper that can be used to print images. |
Public functions |
|
|---|---|
Int |
Gets the color mode with which the image will be printed. |
Int |
Gets whether the image will be printed in landscape or portrait. |
Int |
Returns the scale mode with which the image will fill the paper. |
Unit |
printBitmap(jobName: String, bitmap: Bitmap)Prints a bitmap. |
Unit |
printBitmap(jobName: String, imageFile: Uri)Prints an image located at the Uri. |
Unit |
printBitmap(Prints a bitmap. |
Unit |
printBitmap(Prints an image located at the Uri. |
Unit |
setColorMode(colorMode: Int)Sets whether the image will be printed in color (default) |
Unit |
setOrientation(orientation: Int)Sets whether the image will be printed in landscape |
Unit |
setScaleMode(scaleMode: Int)Selects whether the image will fill the paper and be cropped |
java-static Boolean |
Gets whether the system supports printing. |
Constants
COLOR_MODE_MONOCHROME
const val COLOR_MODE_MONOCHROME = 1: Int
this is a black and white image
ORIENTATION_LANDSCAPE
const val ORIENTATION_LANDSCAPE = 1: Int
Print the image in landscape orientation (default).
ORIENTATION_PORTRAIT
const val ORIENTATION_PORTRAIT = 2: Int
Print the image in portrait orientation.
SCALE_MODE_FILL
const val SCALE_MODE_FILL = 2: Int
image will fill the paper and be cropped (default)
SCALE_MODE_FIT
const val SCALE_MODE_FIT = 1: Int
image will be scaled but leave white space
Public constructors
PrintHelper
PrintHelper(context: Context)
Constructs the PrintHelper that can be used to print images.
| Parameters | |
|---|---|
context: Context |
A context for accessing system resources. |
Public functions
getColorMode
fun getColorMode(): Int
Gets the color mode with which the image will be printed.
| Returns | |
|---|---|
Int |
The color mode which is one of |
getOrientation
fun getOrientation(): Int
Gets whether the image will be printed in landscape or portrait.
| Returns | |
|---|---|
Int |
The page orientation which is one of |
getScaleMode
fun getScaleMode(): Int
Returns the scale mode with which the image will fill the paper.
| Returns | |
|---|---|
Int |
The scale Mode: |
printBitmap
fun printBitmap(jobName: String, imageFile: Uri): Unit
Prints an image located at the Uri. Image types supported are those of android.graphics.BitmapFactory.decodeStream(java.io.InputStream)
| Parameters | |
|---|---|
jobName: String |
The print job name. |
imageFile: Uri |
The |
| Throws | |
|---|---|
java.io.FileNotFoundException |
if |
printBitmap
fun printBitmap(
jobName: String,
bitmap: Bitmap,
callback: PrintHelper.OnPrintFinishCallback?
): Unit
Prints a bitmap.
| Parameters | |
|---|---|
jobName: String |
The print job name. |
bitmap: Bitmap |
The bitmap to print. |
callback: PrintHelper.OnPrintFinishCallback? |
Optional callback to observe when printing is finished. |
printBitmap
fun printBitmap(
jobName: String,
imageFile: Uri,
callback: PrintHelper.OnPrintFinishCallback?
): Unit
Prints an image located at the Uri. Image types supported are those of android.graphics.BitmapFactory.decodeStream(java.io.InputStream)
| Parameters | |
|---|---|
jobName: String |
The print job name. |
imageFile: Uri |
The |
callback: PrintHelper.OnPrintFinishCallback? |
Optional callback to observe when printing is finished. |
| Throws | |
|---|---|
java.io.FileNotFoundException |
if |
setColorMode
fun setColorMode(colorMode: Int): Unit
Sets whether the image will be printed in color (default) COLOR_MODE_COLOR or in back and white COLOR_MODE_MONOCHROME.
| Parameters | |
|---|---|
colorMode: Int |
The color mode which is one of |
setOrientation
fun setOrientation(orientation: Int): Unit
Sets whether the image will be printed in landscape ORIENTATION_LANDSCAPE (default) or portrait ORIENTATION_PORTRAIT.
| Parameters | |
|---|---|
orientation: Int |
The page orientation which is one of |
setScaleMode
fun setScaleMode(scaleMode: Int): Unit
Selects whether the image will fill the paper and be cropped SCALE_MODE_FIT or whether the image will be scaled but leave white space SCALE_MODE_FILL.
| Parameters | |
|---|---|
scaleMode: Int |
systemSupportsPrint
java-static fun systemSupportsPrint(): Boolean
Gets whether the system supports printing.
| Returns | |
|---|---|
Boolean |
True if printing is supported. |