# PrinterCapabilitiesInfo.Builder

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

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

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                 ||
| ↳ | [android.print.PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) |

Builder for creating of a[PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo). This class is responsible to enforce that all required attributes have at least one default value. In other words, this class creates only well-formed[PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo)s.

Look at the individual methods for a reference whether a property is required or if it is optional.

## Summary

|                                                                                                                            Public constructors                                                                                                                            ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#Builder(android.print.PrinterId))`(`printerId:` `[PrinterId](https://developer.android.com/reference/kotlin/android/print/PrinterId)`)` Creates a new instance. |

|                                                                                                                                                                                                                                                                                           Public methods                                                                                                                                                                                                                                                                                           ||
|----------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | [addMediaSize](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#addMediaSize(android.print.PrintAttributes.MediaSize,%20kotlin.Boolean))`(`mediaSize:` `[PrintAttributes.MediaSize](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.MediaSize)`, `isDefault:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Adds a supported media size.       |
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | [addResolution](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#addResolution(android.print.PrintAttributes.Resolution,%20kotlin.Boolean))`(`resolution:` `[PrintAttributes.Resolution](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Resolution)`, `isDefault:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Adds a supported resolution. |
| [PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo)                  | [build](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#build())`()` Crates a new[PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo)enforcing that all required properties have been specified.                                                                                                                                                         |
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | [setColorModes](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#setColorModes(kotlin.Int,%20kotlin.Int))`(`colorModes:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `defaultColorMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the color modes.                                                                                      |
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | [setDuplexModes](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#setDuplexModes(kotlin.Int,%20kotlin.Int))`(`duplexModes:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `defaultDuplexMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the duplex modes.                                                                                 |
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | [setMinMargins](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#setMinMargins(android.print.PrintAttributes.Margins))`(`margins:` `[PrintAttributes.Margins](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Margins)`)` Sets the minimal margins.                                                                                                                                     |

## Public constructors

### Builder

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
Builder(printerId: PrinterId)
```

Creates a new instance.

|                                                            Parameters                                                             ||
|-------------|----------------------------------------------------------------------------------------------------------------------|
| `printerId` | [PrinterId](https://developer.android.com/reference/kotlin/android/print/PrinterId):The printer id. Cannot be`null`. |

|                            Exceptions                             ||
|--------------------------------------|-----------------------------|
| `java.lang.IllegalArgumentException` | If the printer id is`null`. |

## Public methods

### addMediaSize

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun addMediaSize(
    mediaSize: PrintAttributes.MediaSize, 
    isDefault: Boolean
): PrinterCapabilitiesInfo.Builder
```

Adds a supported media size.

**Required:**Yes

|                                                                                 Parameters                                                                                 ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `mediaSize` | [PrintAttributes.MediaSize](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.MediaSize):A media size. This value cannot be`null`. |
| `isDefault` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):Whether this is the default.                                               |

|                                                                                   Return                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | This builder. This value cannot be`null`. |

|                                       Exceptions                                        ||
|--------------------------------------|---------------------------------------------------|
| `java.lang.IllegalArgumentException` | If set as default and there is already a default. |

**See Also**

- [android.print.PrintAttributes.MediaSize](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.MediaSize)  

### addResolution

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun addResolution(
    resolution: PrintAttributes.Resolution, 
    isDefault: Boolean
): PrinterCapabilitiesInfo.Builder
```

Adds a supported resolution.

**Required:**Yes

|                                                                                  Parameters                                                                                   ||
|--------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `resolution` | [PrintAttributes.Resolution](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Resolution):A resolution. This value cannot be`null`. |
| `isDefault`  | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):Whether this is the default.                                                 |

|                                                                                   Return                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | This builder. This value cannot be`null`. |

|                                       Exceptions                                        ||
|--------------------------------------|---------------------------------------------------|
| `java.lang.IllegalArgumentException` | If set as default and there is already a default. |

**See Also**

- [android.print.PrintAttributes.Resolution](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Resolution)  

### build

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun build(): PrinterCapabilitiesInfo
```

Crates a new[PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo)enforcing that all required properties have been specified. See individual methods in this class for reference about required attributes.

**Note:** If you do not add supported duplex modes,[android.print.PrintAttributes#DUPLEX_MODE_NONE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_NONE:kotlin.Int)will set as the only supported mode and also as the default duplex mode.

|                                                                                                                               Return                                                                                                                               ||
|-----------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo) | A new[PrinterCapabilitiesInfo](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo). This value cannot be`null`. |

|                                  Exceptions                                   ||
|-----------------------------------|--------------------------------------------|
| `java.lang.IllegalStateException` | If a required attribute was not specified. |

### setColorModes

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setColorModes(
    colorModes: Int, 
    defaultColorMode: Int
): PrinterCapabilitiesInfo.Builder
```

Sets the color modes.

**Required:**Yes

|                                                                                                                                                                                                                                            Parameters                                                                                                                                                                                                                                            ||
|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `colorModes`       | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The color mode bit mask. Value is either`0`or a combination of[android.print.PrintAttributes#COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#COLOR_MODE_MONOCHROME:kotlin.Int), and[android.print.PrintAttributes#COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#COLOR_MODE_COLOR:kotlin.Int) |
| `defaultColorMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The default color mode. Value is either`0`or a combination of[android.print.PrintAttributes#COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#COLOR_MODE_MONOCHROME:kotlin.Int), and[android.print.PrintAttributes#COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#COLOR_MODE_COLOR:kotlin.Int)  |

|                                                                                                                                                                                              Return                                                                                                                                                                                               ||
|----------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | This builder. **Note:**On platform version 19 (Kitkat) specifying only PrintAttributes#COLOR_MODE_MONOCHROME leads to a print spooler crash. Hence, you should declare either both color modes or PrintAttributes#COLOR_MODE_COLOR. This value cannot be`null`. |

|                                                         Exceptions                                                         ||
|--------------------------------------|--------------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | If color modes contains an invalid mode bit or if the default color mode is invalid. |

**See Also**

- [android.print.PrintAttributes#COLOR_MODE_COLOR](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#COLOR_MODE_COLOR:kotlin.Int)
- [android.print.PrintAttributes#COLOR_MODE_MONOCHROME](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#COLOR_MODE_MONOCHROME:kotlin.Int)  

### setDuplexModes

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setDuplexModes(
    duplexModes: Int, 
    defaultDuplexMode: Int
): PrinterCapabilitiesInfo.Builder
```

Sets the duplex modes.

**Required:**No

|                                                                                                                                                                                                                                                                                                                                Parameters                                                                                                                                                                                                                                                                                                                                 ||
|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `duplexModes`       | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The duplex mode bit mask. Value is either`0`or a combination of[android.print.PrintAttributes#DUPLEX_MODE_NONE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_NONE:kotlin.Int),[android.print.PrintAttributes#DUPLEX_MODE_LONG_EDGE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_LONG_EDGE:kotlin.Int), and[android.print.PrintAttributes#DUPLEX_MODE_SHORT_EDGE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_SHORT_EDGE:kotlin.Int) |
| `defaultDuplexMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):The default duplex mode. Value is either`0`or a combination of[android.print.PrintAttributes#DUPLEX_MODE_NONE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_NONE:kotlin.Int),[android.print.PrintAttributes#DUPLEX_MODE_LONG_EDGE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_LONG_EDGE:kotlin.Int), and[android.print.PrintAttributes#DUPLEX_MODE_SHORT_EDGE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_SHORT_EDGE:kotlin.Int)  |

|                                                                                   Return                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | This builder. This value cannot be`null`. |

|                                                          Exceptions                                                          ||
|--------------------------------------|----------------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | If duplex modes contains an invalid mode bit or if the default duplex mode is invalid. |

**See Also**

- [android.print.PrintAttributes#DUPLEX_MODE_NONE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_NONE:kotlin.Int)
- [android.print.PrintAttributes#DUPLEX_MODE_LONG_EDGE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_LONG_EDGE:kotlin.Int)
- [android.print.PrintAttributes#DUPLEX_MODE_SHORT_EDGE](https://developer.android.com/reference/kotlin/android/print/PrintAttributes#DUPLEX_MODE_SHORT_EDGE:kotlin.Int)  

### setMinMargins

Added in[API level 19](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun setMinMargins(margins: PrintAttributes.Margins): PrinterCapabilitiesInfo.Builder
```

Sets the minimal margins. These are the minimal margins the printer physically supports.

**Required:**Yes

|                                                                             Parameters                                                                              ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `margins` | [PrintAttributes.Margins](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Margins):The margins. This value cannot be`null`. |

|                                                                                   Return                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [PrinterCapabilitiesInfo.Builder](https://developer.android.com/reference/kotlin/android/print/PrinterCapabilitiesInfo.Builder#) | This builder. This value cannot be`null`. |

|                         Exceptions                          ||
|--------------------------------------|-----------------------|
| `java.lang.IllegalArgumentException` | If margins are`null`. |

**See Also**

- [android.print.PrintAttributes.Margins](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Margins)