# PrintHelper

# PrintHelper

Artifact:[androidx.print:print](https://developer.android.com/jetpack/androidx/releases/print)  
[View Source](https://cs.android.com/search?q=file:androidx/print/PrintHelper.java+class:androidx.print.PrintHelper)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/print/PrintHelper "View this page in Java")

<br />

```
class PrintHelper
```

<br />

*** ** * ** ***

Helper for printing bitmaps.

## Summary

|                                                                                               ### Nested types                                                                                               |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `interface `[PrintHelper.OnPrintFinishCallback](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper.OnPrintFinishCallback) Callback for observing when a print operation is completed. |

|                                    ### Constants                                    |
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_COLOR())` = 2` this is a color image (default)                               |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_MONOCHROME())` = 1` this is a black and white image                     |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [ORIENTATION_LANDSCAPE](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_LANDSCAPE())` = 1` Print the image in landscape orientation (default). |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [ORIENTATION_PORTRAIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_PORTRAIT())` = 2` Print the image in portrait orientation.              |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SCALE_MODE_FILL](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FILL())` = 2` image will fill the paper and be cropped (default)              |
| `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SCALE_MODE_FIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FIT())` = 1` image will be scaled but leave white space                        |

|                                                                                                                                 ### Public constructors                                                                                                                                  |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PrintHelper](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#PrintHelper(android.content.Context))`(context: `[Context](https://developer.android.com/reference/android/content/Context.html)`)` Constructs the PrintHelper that can be used to print images. |

|                                       ### Public functions                                        |
|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                       | [getColorMode](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#getColorMode())`()` Gets the color mode with which the image will be printed.                                                                                                                                                                                                                                                                                                                                                                                                        |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                       | [getOrientation](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#getOrientation())`()` Gets whether the image will be printed in landscape or portrait.                                                                                                                                                                                                                                                                                                                                                                                             |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                       | [getScaleMode](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#getScaleMode())`()` Returns the scale mode with which the image will fill the paper.                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [printBitmap](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#printBitmap(java.lang.String,android.graphics.Bitmap))`(jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, bitmap: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`)` Prints a bitmap.                                                                                                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [printBitmap](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#printBitmap(java.lang.String,android.net.Uri))`(jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, imageFile: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`)` Prints an image located at the Uri.                                                                                                                                                                                                                  |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [printBitmap](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#printBitmap(java.lang.String,android.graphics.Bitmap,androidx.print.PrintHelper.OnPrintFinishCallback))`(` ` jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` bitmap: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)`,` ` callback: `[PrintHelper.OnPrintFinishCallback](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper.OnPrintFinishCallback)`?` `)` Prints a bitmap.    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [printBitmap](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#printBitmap(java.lang.String,android.net.Uri,androidx.print.PrintHelper.OnPrintFinishCallback))`(` ` jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` imageFile: `[Uri](https://developer.android.com/reference/android/net/Uri.html)`,` ` callback: `[PrintHelper.OnPrintFinishCallback](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper.OnPrintFinishCallback)`?` `)` Prints an image located at the Uri. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [setColorMode](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#setColorMode(int))`(colorMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets whether the image will be printed in color (default)[COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_COLOR())or in back and white[COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_MONOCHROME()).                                              |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [setOrientation](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#setOrientation(int))`(orientation: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Sets whether the image will be printed in landscape[ORIENTATION_LANDSCAPE](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_LANDSCAPE())(default) or portrait[ORIENTATION_PORTRAIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_PORTRAIT()).                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)                     | [setScaleMode](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#setScaleMode(int))`(scaleMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Selects whether the image will fill the paper and be cropped[SCALE_MODE_FIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FIT())or whether the image will be scaled but leave white space[SCALE_MODE_FILL](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FILL()).                      |
| `java-static `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [systemSupportsPrint](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#systemSupportsPrint())`()` Gets whether the system supports printing.                                                                                                                                                                                                                                                                                                                                                                                                         |

## Constants

### COLOR_MODE_COLOR

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
const val COLOR_MODE_COLOR = 2: Int
```

this is a color image (default)  

### COLOR_MODE_MONOCHROME

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
const val COLOR_MODE_MONOCHROME = 1: Int
```

this is a black and white image  

### ORIENTATION_LANDSCAPE

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
const val ORIENTATION_LANDSCAPE = 1: Int
```

Print the image in landscape orientation (default).  

### ORIENTATION_PORTRAIT

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
const val ORIENTATION_PORTRAIT = 2: Int
```

Print the image in portrait orientation.  

### SCALE_MODE_FILL

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
const val SCALE_MODE_FILL = 2: Int
```

image will fill the paper and be cropped (default)  

### SCALE_MODE_FIT

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
const val SCALE_MODE_FIT = 1: Int
```

image will be scaled but leave white space  

## Public constructors

### PrintHelper

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
PrintHelper(context: Context)
```

Constructs the PrintHelper that can be used to print images.  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|-------------------------------------------|
| `context: `[Context](https://developer.android.com/reference/android/content/Context.html) | A context for accessing system resources. |

## Public functions

### getColorMode

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun getColorMode(): Int
```

Gets the color mode with which the image will be printed.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The color mode which is one of[COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_COLOR())and[COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_MONOCHROME()). |

### getOrientation

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun getOrientation(): Int
```

Gets whether the image will be printed in landscape or portrait.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The page orientation which is one of[ORIENTATION_LANDSCAPE](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_LANDSCAPE())or[ORIENTATION_PORTRAIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_PORTRAIT()). |

### getScaleMode

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun getScaleMode(): Int
```

Returns the scale mode with which the image will fill the paper.  

|                                   Returns                                   |
|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The scale Mode:[SCALE_MODE_FIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FIT())or[SCALE_MODE_FILL](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FILL()) |

### printBitmap

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun printBitmap(jobName: String, bitmap: Bitmap): Unit
```

Prints a bitmap.  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|----------------------|
| `jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The print job name.  |
| `bitmap: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)     | The bitmap to print. |

### printBitmap

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
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)](https://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeStream(java.io.InputStream))  

|                                          Parameters                                          |
|----------------------------------------------------------------------------------------------|----------------------------------------|
| `jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The print job name.                    |
| `imageFile: `[Uri](https://developer.android.com/reference/android/net/Uri.html)             | The`Uri`pointing to an image to print. |

|                                                   Throws                                                    |
|-------------------------------------------------------------------------------------------------------------|------------------------------------------|
| [java.io.FileNotFoundException](https://developer.android.com/reference/java/io/FileNotFoundException.html) | if`Uri`is not pointing to a valid image. |

### printBitmap

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun printBitmap(
    jobName: String,
    bitmap: Bitmap,
    callback: PrintHelper.OnPrintFinishCallback?
): Unit
```

Prints a bitmap.  

|                                                                     Parameters                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| `jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                        | The print job name.                                     |
| `bitmap: `[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html)                                                            | The bitmap to print.                                    |
| `callback: `[PrintHelper.OnPrintFinishCallback](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper.OnPrintFinishCallback)`?` | Optional callback to observe when printing is finished. |

### printBitmap

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
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)](https://developer.android.com/reference/android/graphics/BitmapFactory.html#decodeStream(java.io.InputStream))  

|                                                                     Parameters                                                                      |
|-----------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| `jobName: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                        | The print job name.                                     |
| `imageFile: `[Uri](https://developer.android.com/reference/android/net/Uri.html)                                                                    | The`Uri`pointing to an image to print.                  |
| `callback: `[PrintHelper.OnPrintFinishCallback](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper.OnPrintFinishCallback)`?` | Optional callback to observe when printing is finished. |

|                                                   Throws                                                    |
|-------------------------------------------------------------------------------------------------------------|------------------------------------------|
| [java.io.FileNotFoundException](https://developer.android.com/reference/java/io/FileNotFoundException.html) | if`Uri`is not pointing to a valid image. |

### setColorMode

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun setColorMode(colorMode: Int): Unit
```

Sets whether the image will be printed in color (default)[COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_COLOR())or in back and white[COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_MONOCHROME()).  

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `colorMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The color mode which is one of[COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_COLOR())and[COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#COLOR_MODE_MONOCHROME()). |

### setOrientation

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun setOrientation(orientation: Int): Unit
```

Sets whether the image will be printed in landscape[ORIENTATION_LANDSCAPE](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_LANDSCAPE())(default) or portrait[ORIENTATION_PORTRAIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_PORTRAIT()).  

|                                         Parameters                                         |
|--------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `orientation: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The page orientation which is one of[ORIENTATION_LANDSCAPE](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_LANDSCAPE())or[ORIENTATION_PORTRAIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#ORIENTATION_PORTRAIT()). |

### setScaleMode

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
fun setScaleMode(scaleMode: Int): Unit
```

Selects whether the image will fill the paper and be cropped[SCALE_MODE_FIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FIT())or whether the image will be scaled but leave white space[SCALE_MODE_FILL](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FILL()).  

|                                        Parameters                                        |
|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `scaleMode: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SCALE_MODE_FIT](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FIT())or[SCALE_MODE_FILL](https://developer.android.com/reference/kotlin/androidx/print/PrintHelper#SCALE_MODE_FILL()) |

### systemSupportsPrint

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/print#1.0.0)  

```
java-static fun systemSupportsPrint(): Boolean
```

Gets whether the system supports printing.  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|--------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | True if printing is supported. |