> For the complete documentation index, see [llms.txt](https://docs.emobiq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/printer/canvastocpcl.md).

# canvasToCPCL

## Description

Converts a canvas to CPCL (Comtec Printer Control Language), a programming language used by printers.

## Input / Parameter

| Name        | Description                        | Input Type  | Default | Options     | Required |
| ----------- | ---------------------------------- | ----------- | ------- | ----------- | -------- |
| canvas      | The name of the canvas to convert. | String/Text | -       | -           | Yes      |
| singlePrint | To print single-sided or not.      | Boolean     | true    | true, false | No       |
| copies      | The number of copies to print.     | Number      | 1       | -           | No       |
| blackMark   | To show black mark or not.         | Boolean     | false?  | true, false | No       |

## Output

N/A

## Callback

N/A

## Video

Coming Soon.

## Example

### Steps

1. In this example, we will connect to a bluetooth printer, use `canvasToCPCL` to convert a canvas to CPCL which will be sent to the printer for printing.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-e25104c258c2dc6db53f06240e632f8f27661902%2FcanvasToCPCL-step-1.png?alt=media)
2. For `btPrinterConnect`, enter the `printerId` of the bluetooth printer.
3. For `canvasGenerateFrom`, enter the details of the image or PDF to be converted to canvas. In this example we are using a base64 string of an image.

   | Field    | Value                                   |
   | -------- | --------------------------------------- |
   | type     | base64                                  |
   | value    | *(base64-encoded string of your image)* |
   | fileType | image                                   |

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-16357c7ef9effe71994c96225bca3276222f7441%2FcanvasToCPCL-step-2.png?alt=media)
4. For `btPrinterPrint`, under the "text" field, add a function `canvasToCPCL` to convert the canvas format into CPCL (a language used by thermal printers).

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

### Result

Image will be printed by the connected bluetooth printer.

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

## Links
