# wmpf.printer(Object object)

Delivering Text Content to Device Printer Service - Asynchronous return

The following parameters are just examples, but the following values will be transmitted as JSON at actual runtime WMPF Client for use by developers. The JSON content and fields do not require formatting, and the parameter content contained in the example only provides reference and suggestions for specific business scenarios.

# parameter

# Object object

attribute type Introductions
type string Print Type: base_string, ext_string, both_side, barcode, qrcode, image
content string Printed content: both_side Type is json string {"left","text on the left","right":"text on the right"} 。image Type for the picture base64 coding
style Object Font style
barCodeOption Object qrcode to set
imageOption Object If the width exceeds the width of the printing paper, the printing will not be complete.

# style

attribute type Introductions
fontSize int Text size
align string Text position, optional value: left / center / right. The default value is center
bold int Whether in bold, int Type: 0 No, 1 yes The default value is 0
italic int Italic, int Type: 0 No, 1 yes The default value is 0
Underline int Whether to underline, int Type: 0 No, 1 yes The default value is 0 。ext_string, both_side Type Applicable
leftOffset int Left offset, int Type: The default value is 0 。ext_string Type Applicable
letterWidth float Letter width, float Type: The default value is 0 。ext_string Type Applicable
lineSpacing float Row spacing, float Type: The default value is 1 。ext_string, both_side Type Applicable
font string Font, optional value: default / default_bold / minivan / serif / sans_serif The default value is default 。ext_string, both_side Type Applicable

# barCodeOption

parameter type Introductions
width int Width, int Type. The default value is 400

# imageOption

attribute type Introductions
width int Width, int type
height int 初始值 type
align string Image position, optional: left / center / right The default value is center
offset int Offset value, int Type. The default value is 0

# Return value

attribute type Introductions
errMsg string Success: Ok, error: fail
errCode number errMsg for fail Pass through the return value of the printer service

# sample code

wmpf.printer({
  data: [ // data All the information in the Intent Extra Data to hit the target raw_data data	
    初始值
      "type": "base_string",
      "content": "XXXX Information Technology Limited Company,"
      "style": {
        "fontSize": 30,
        "bold": 1
      }

    },
    {
      "type": "base_string",
      "content": "Customer Information,"
      "style": {
        "fontSize": 25,
        "bold": 1
      }

    },
    {
      "type": "both_side",
      "content": {
        "left": "Customer Name,"
        "right": "Kommi"
      },
      "style": {
        "fontSize": 20,
        "bold": 0
      }

    },
    {
      "type": "base_string",
      "content": "Other Information,"
      "style": {
        "fontSize": 25,
        "bold": 1
      }

    },
    {
      "type": "both_side",
      "content": {
        "left": "write-off stores,"
        "right": "407 State Road for you."
      },
      "style": {
        "fontSize": 20,
        "bold": 0
      }

    },
    {
      "type": "both_side",
      "content": {
        "left": "verification code,"
        "right": "5665470281092409"
      },
      "style": {
        "fontSize": 20,
        "bold": 0
      }

    },
    {
      "type": "barcode",
      "content": "5665470281092409",
      "barCodeOption": {
        "barWidth": "normal",
      }

    }

  ],
  success: (res) => {
    console.log(res)
  },
  fail: (res) => {
    console.log(res)
  }
})