# PrintAttributes.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/PrintAttributes.Builder "View this page in Java")  

```
class Builder
```

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

Builder for creating[PrintAttributes](https://developer.android.com/reference/kotlin/android/print/PrintAttributes).

## Summary

|                                                   Public constructors                                                   ||
|----------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#Builder())`()` <br /> |

|                                                                                                                                                                                                                Public methods                                                                                                                                                                                                                 ||
|------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [PrintAttributes](https://developer.android.com/reference/kotlin/android/print/PrintAttributes)                  | [build](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#build())`()` Creates a new[PrintAttributes](https://developer.android.com/reference/kotlin/android/print/PrintAttributes)instance.                                                                                             |
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | [setColorMode](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#setColorMode(kotlin.Int))`(`colorMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the color mode.                                                                             |
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | [setDuplexMode](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#setDuplexMode(kotlin.Int))`(`duplexMode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the duplex mode.                                                                         |
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | [setMediaSize](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#setMediaSize(android.print.PrintAttributes.MediaSize))`(`mediaSize:` `[PrintAttributes.MediaSize](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.MediaSize)`)` Sets the media size.       |
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | [setMinMargins](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#setMinMargins(android.print.PrintAttributes.Margins))`(`margins:` `[PrintAttributes.Margins](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Margins)`)` Sets the minimal margins.        |
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | [setResolution](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#setResolution(android.print.PrintAttributes.Resolution))`(`resolution:` `[PrintAttributes.Resolution](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Resolution)`)` Sets the resolution. |

## Public constructors

### Builder

```
Builder()
```

## Public methods

### build

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

```
fun build(): PrintAttributes
```

Creates a new[PrintAttributes](https://developer.android.com/reference/kotlin/android/print/PrintAttributes)instance.

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

### setColorMode

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

```
fun setColorMode(colorMode: Int): PrintAttributes.Builder
```

Sets the color mode.

|                                                                                                                                                                                                                                          Parameters                                                                                                                                                                                                                                          ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `colorMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):A valid color mode or zero. 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                                                                            ||
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | This builder. This value cannot be`null`. |

**See Also**

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

### setDuplexMode

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

```
fun setDuplexMode(duplexMode: Int): PrintAttributes.Builder
```

Sets the duplex mode.

|                                                                                                                                                                                                                                                                                                                              Parameters                                                                                                                                                                                                                                                                                                                               ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `duplexMode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):A valid duplex mode or zero. 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                                                                            ||
|------------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [PrintAttributes.Builder](https://developer.android.com/reference/kotlin/android/print/PrintAttributes.Builder#) | This builder. This value cannot be`null`. |

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

### setMediaSize

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

```
fun setMediaSize(mediaSize: PrintAttributes.MediaSize): PrintAttributes.Builder
```

Sets the media size.

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

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

### setMinMargins

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

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

Sets the minimal margins. If the content does not fit these margins it will be clipped.

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

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

### setResolution

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

```
fun setResolution(resolution: PrintAttributes.Resolution): PrintAttributes.Builder
```

Sets the resolution.

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

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