# Control the Device Printer

This guide explains how to interact with the device's physical hardware—specifically the printer—using the `PrinterRepository`. This allows you to check for paper availability and print both standard receipts and custom content.

## Checking Paper Status

Before attempting any print job, it is best practice to verify that the printer has paper. Use the `checkPaper` function to query the hardware status.

**Repository**: `PrinterRepository`

**Function**: `checkPaper`

### Example Implementation

Returns `true` if paper is available, `false` otherwise .

```kotlin
suspend fun verifyPaperAvailability() {
    val result = printerRepository.checkPaper()

    when (result) {
        is RepositoryResult.Success -> {
            val hasPaper = result.data
            if (hasPaper) {
                println("✅ Printer is ready.")
            } else {
                println("⚠️ Printer is out of paper.")
            }
        }
        is RepositoryResult.ConnectionError -> println("❌ Connection Error")
        is RepositoryResult.ProtocolError -> println("❌ Error: ${result.type}")
        else -> {}
    }
}
```

## Printing a Default Ticket

The SDK provides a built-in method to generate and print a standard receipt using data from a `Transaction` object. This is useful for quickly generating compliant receipts without manually drawing the layout.

**Function**: `printDefaultTicket`

**Parameters**:

* `context`: The Android application context.  
* `headerIcon`: A `Bitmap` image to print at the top of the receipt (e.g., your merchant logo).  
* `transaction`: The `Transaction` object containing the payment details.

### Example Implementation

```kotlin
suspend fun printReceipt(context: Context, logo: Bitmap, transaction: Transaction) {
    val result = printerRepository.printDefaultTicket(
        context = context,
        headerIcon = logo,
        transaction = transaction
    )

    handlePrintResult(result)
}
```

## Printing Custom Content (Bitmaps)

If you need full control over the receipt design (e.g., adding coupons, QR codes, or custom layouts), you can render your content into a `Bitmap` and send it directly to the printer.

**Function**: `printBitmap`

**Parameters**:

* `bitmap`: The `Bitmap` object to print.

### Example Implementation

```kotlin
suspend fun printCustomDesign(myCustomBitmap: Bitmap) {
    val result = printerRepository.printBitmap(
        bitmap = myCustomBitmap
    )

    handlePrintResult(result)
}
```

## Handling Print Results

Both printing methods return a `RepositoryResult<Boolean>`.

```kotlin
fun handlePrintResult(result: RepositoryResult<Boolean>) {
    when (result) {
        is RepositoryResult.Success -> {
            if (result.data) {
                println("✅ Print job completed successfully.")
            } else {
                println("❌ Print job failed.")
            }
        }
        is RepositoryResult.ConnectionError -> println("❌ Connection Error")
        is RepositoryResult.ProtocolError -> println("❌ Protocol Error: ${result.type}")
        else -> {}
    }
}
```

## Next Steps

* [**Configure Bizum Payments**](/en/get-smart/get-smart-sdk/integration-guides/alternative-payment-methods-apms/configure-bizum-payments): Integration guides for Bizum.
* [**Configure Alipay and WeChat QR**](/en/get-smart/get-smart-sdk/integration-guides/alternative-payment-methods-apms/configure-alipay-and-wechat-qr): Integration guides for Alipay and WeChat Pay using QR-based flows.  
* [**Manage Device Settings**](/en/get-smart/get-smart-sdk/integration-guides/device-and-quality-assurance/manage-device-settings): Learn how to manage device settings.
* [**Tokenize Card Credentials**](/en/get-smart/get-smart-sdk/integration-guides/device-and-quality-assurance/tokenize-card-credentials): Learn how to manage tokens.