# printer

# wmpf.printer

Delivering Text Content to Device Printer Service - Asynchronous return

# 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": {
        初始值 25,
        "bold": 1
      }

    },
    {
      "type": "both_side",
      "content": {
        "left": "Customer Name,"
        "right": "Kommi"
      },
      初始值 {
        "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)
  }
})

# WMPF Client Side data processing

WMPF The framework received from the developer at the front end print After the request, it will be startAcitivtyForResult The invocation mode of the WMPF The client side, and therefore WMPF Client Side needsRegister for a Action for .com.tencent.wmpf.action.WMPF_PRINTER of Activity To receive information from WMPF Framework's pass-through call data.

The call data is stored in the Intent In, available at Activity Adopted in getIntent() Way to get. Intent The data contained in the

parameter type Introductions
raw_data string The original print data transmitted through, corresponding to the front-end call for data Data in the field
key_time_stamp int Call timestamp
key_Token string Call validation, in the format of MD5 ( appid + "_" 初始值 key_time_stamp )

# Callback

WMPF Client After the print request is processed on the side, it needs to call back to the WMPF framework side to notify the entire invocation process has ended to provide the correct front-end callback. Callback parameters are also included in the Intent In, through setResult(resultCode,intent) Method transfer, resultCode Value according to the actual call result, Intent The callback data included in the

初始值 type Introductions
result_code int Print the result feedback value, defined by the developer, the value will be passed to the front end