# PrintHelper

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:print:28.0.0-alpha1  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v4/print/PrintHelper#nestedclasses)\|[Constants](https://developer.android.com/reference/android/support/v4/print/PrintHelper#constants)\|[Ctors](https://developer.android.com/reference/android/support/v4/print/PrintHelper#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v4/print/PrintHelper#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v4/print/PrintHelper#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v4/print/PrintHelper#)  

# PrintHelper

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
PrintHelper
`  
`

extends Object


``


`

|---|--------------------------------------|
| java.lang.Object                        ||
| ↳ | android.support.v4.print.PrintHelper |

<br />

*** ** * ** ***

Helper for printing bitmaps.

## Summary

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

|                                                                                     ### Constants                                                                                      ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | [COLOR_MODE_COLOR](https://developer.android.com/reference/android/support/v4/print/PrintHelper#COLOR_MODE_COLOR) this is a color image (default)                               |
| `int` | [COLOR_MODE_MONOCHROME](https://developer.android.com/reference/android/support/v4/print/PrintHelper#COLOR_MODE_MONOCHROME) this is a black and white image                     |
| `int` | [ORIENTATION_LANDSCAPE](https://developer.android.com/reference/android/support/v4/print/PrintHelper#ORIENTATION_LANDSCAPE) Print the image in landscape orientation (default). |
| `int` | [ORIENTATION_PORTRAIT](https://developer.android.com/reference/android/support/v4/print/PrintHelper#ORIENTATION_PORTRAIT) Print the image in portrait orientation.              |
| `int` | [SCALE_MODE_FILL](https://developer.android.com/reference/android/support/v4/print/PrintHelper#SCALE_MODE_FILL) image will fill the paper and be cropped (default)              |
| `int` | [SCALE_MODE_FIT](https://developer.android.com/reference/android/support/v4/print/PrintHelper#SCALE_MODE_FIT) image will be scaled but leave white space                        |

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

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

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v4/print/PrintHelper#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Constants

### COLOR_MODE_COLOR

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int COLOR_MODE_COLOR
```

this is a color image (default)

<br />

Constant Value: 2 (0x00000002)  

### COLOR_MODE_MONOCHROME

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int COLOR_MODE_MONOCHROME
```

this is a black and white image

<br />

Constant Value: 1 (0x00000001)  

### ORIENTATION_LANDSCAPE

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int ORIENTATION_LANDSCAPE
```

Print the image in landscape orientation (default).

<br />

Constant Value: 1 (0x00000001)  

### ORIENTATION_PORTRAIT

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int ORIENTATION_PORTRAIT
```

Print the image in portrait orientation.

<br />

Constant Value: 2 (0x00000002)  

### SCALE_MODE_FILL

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int SCALE_MODE_FILL
```

image will fill the paper and be cropped (default)

<br />

Constant Value: 2 (0x00000002)  

### SCALE_MODE_FIT

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int SCALE_MODE_FIT
```

image will be scaled but leave white space

<br />

Constant Value: 1 (0x00000001)

## Public constructors

### PrintHelper

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
PrintHelper (Context context)
```

Constructs the PrintHelper that can be used to print images.

<br />

|                               Parameters                               ||
|-----------|-------------------------------------------------------------|
| `context` | `Context`: A context for accessing system resources. <br /> |

## Public methods

### getColorMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getColorMode ()
```

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

<br />

|                                                                                                                                           Returns                                                                                                                                            ||
|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | The color mode which is one of[COLOR_MODE_COLOR](https://developer.android.com/reference/android/support/v4/print/PrintHelper#COLOR_MODE_COLOR)and[COLOR_MODE_MONOCHROME](https://developer.android.com/reference/android/support/v4/print/PrintHelper#COLOR_MODE_MONOCHROME). <br /> |

### getOrientation

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getOrientation ()
```

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

<br />

|                                                                                                                                                  Returns                                                                                                                                                  ||
|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | The page orientation which is one of[ORIENTATION_LANDSCAPE](https://developer.android.com/reference/android/support/v4/print/PrintHelper#ORIENTATION_LANDSCAPE)or[ORIENTATION_PORTRAIT](https://developer.android.com/reference/android/support/v4/print/PrintHelper#ORIENTATION_PORTRAIT). <br /> |

### getScaleMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
int getScaleMode ()
```

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

<br />

|                                                                                                                           Returns                                                                                                                           ||
|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `int` | The scale Mode:[SCALE_MODE_FIT](https://developer.android.com/reference/android/support/v4/print/PrintHelper#SCALE_MODE_FIT)or[SCALE_MODE_FILL](https://developer.android.com/reference/android/support/v4/print/PrintHelper#SCALE_MODE_FILL) <br /> |

### printBitmap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void printBitmap (String jobName, 
                Bitmap bitmap)
```

Prints a bitmap.

<br />

|                    Parameters                    ||
|-----------|---------------------------------------|
| `jobName` | `String`: The print job name. <br />  |
| `bitmap`  | `Bitmap`: The bitmap to print. <br /> |

### printBitmap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void printBitmap (String jobName, 
                Bitmap bitmap, 
                PrintHelper.OnPrintFinishCallback callback)
```

Prints a bitmap.

<br />

|                                                   Parameters                                                    ||
|------------|-----------------------------------------------------------------------------------------------------|
| `jobName`  | `String`: The print job name. <br />                                                                |
| `bitmap`   | `Bitmap`: The bitmap to print. <br />                                                               |
| `callback` | `PrintHelper.OnPrintFinishCallback`: Optional callback to observe when printing is finished. <br /> |

### printBitmap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void printBitmap (String jobName, 
                Uri imageFile)
```

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

<br />

|                            Parameters                             ||
|-------------|------------------------------------------------------|
| `jobName`   | `String`: The print job name. <br />                 |
| `imageFile` | `Uri`: The`Uri`pointing to an image to print. <br /> |

|                              Throws                               ||
|-------------------------|------------------------------------------|
| `FileNotFoundException` | if`Uri`is not pointing to a valid image. |

### printBitmap

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void printBitmap (String jobName, 
                Uri imageFile, 
                PrintHelper.OnPrintFinishCallback callback)
```

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

<br />

|                                                    Parameters                                                    ||
|-------------|-----------------------------------------------------------------------------------------------------|
| `jobName`   | `String`: The print job name. <br />                                                                |
| `imageFile` | `Uri`: The`Uri`pointing to an image to print. <br />                                                |
| `callback`  | `PrintHelper.OnPrintFinishCallback`: Optional callback to observe when printing is finished. <br /> |

|                              Throws                               ||
|-------------------------|------------------------------------------|
| `FileNotFoundException` | if`Uri`is not pointing to a valid image. |

### setColorMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setColorMode (int colorMode)
```

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

<br />

|                                                                                                                                                Parameters                                                                                                                                                 ||
|-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `colorMode` | `int`: The color mode which is one of[COLOR_MODE_COLOR](https://developer.android.com/reference/android/support/v4/print/PrintHelper#COLOR_MODE_COLOR)and[COLOR_MODE_MONOCHROME](https://developer.android.com/reference/android/support/v4/print/PrintHelper#COLOR_MODE_MONOCHROME). <br /> |

### setOrientation

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setOrientation (int orientation)
```

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

<br />

|                                                                                                                                                        Parameters                                                                                                                                                        ||
|---------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `orientation` | `int`: The page orientation which is one of[ORIENTATION_LANDSCAPE](https://developer.android.com/reference/android/support/v4/print/PrintHelper#ORIENTATION_LANDSCAPE)or[ORIENTATION_PORTRAIT](https://developer.android.com/reference/android/support/v4/print/PrintHelper#ORIENTATION_PORTRAIT). <br /> |

### setScaleMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void setScaleMode (int scaleMode)
```

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

<br />

|                                                                                                                        Parameters                                                                                                                        ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `scaleMode` | `int`:[SCALE_MODE_FIT](https://developer.android.com/reference/android/support/v4/print/PrintHelper#SCALE_MODE_FIT)or[SCALE_MODE_FILL](https://developer.android.com/reference/android/support/v4/print/PrintHelper#SCALE_MODE_FILL) <br /> |

### systemSupportsPrint

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean systemSupportsPrint ()
```

Gets whether the system supports printing.

<br />

|                     Returns                      ||
|-----------|---------------------------------------|
| `boolean` | True if printing is supported. <br /> |

-

  ## Interfaces

  - [PrintHelper.OnPrintFinishCallback](https://developer.android.com/reference/android/support/v4/print/PrintHelper.OnPrintFinishCallback)
-

  ## Classes

  - [PrintHelper](https://developer.android.com/reference/android/support/v4/print/PrintHelper)