# btPrinterPrint

## Description

Sends data to a printer to print the required document.

## Input / Parameter

| Name | Description        | Input Type  | Default | Options | Required |
| ---- | ------------------ | ----------- | ------- | ------- | -------- |
| text | The data to print. | String/Text | -       | -       | Yes      |

## Output

N/A

## Callback

### callback

The function to be executed if the data to be printed is sent to the printer successfully.

### errorCallback

The function to be executed if the data to be printed is not sent to the printer successfully.

## Video

Coming Soon.

## Example

The user wants to print a document from the device.

### Steps

1. Call the function `btPrinterPrint`. Call the function `formatToCPCL` in the `text` parameter of the function to convert the text to CPCL format for printing.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-dcf39f5a4c4ac72776a31323ffbd5165ce604fc7%2FbtPrinterPrint-step-1.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-435409a56d67e4bf434ccf435fe1fac1b1fb1c62%2FbtPrinterPrint-step-2.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9341fa91f403943371c970202ff9a72c0dbe7c70%2FbtPrinterPrint-step-3.png?alt=media)
2. Call the function `infoDialog` in the callbacks of the `btPrinterPrint` function to view the status.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b864b08e7d7b262ebbca8fc4ba08ba03a8b33218%2FbtPrinterPrint-step-4.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-de3df09f09f72cd2919237bc19369072f656aa46%2FbtPrinterPrint-step-5.png?alt=media)

### Result

1. If the document is printed successfully, the success infoDialog will appear, otherwise the error infoDialog will appear.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-961f55c958f95b16e6d82e338f57ecf9b02635e1%2FbtPrinterPrint-result-1.jpg?alt=media)

## Links
