printPr method

Future<CuppsCommandResponse> printPr(
  1. List<String> texts,
  2. List<String> pdfBase64s
)

Implementation

Future<CuppsCommandResponse> printPr(List<String> texts, List<String> pdfBase64s) async {
  PrintRequest req = PrintRequest(messageID: currentMessageID, printDocuments: [
    PrintDocument(
      textDocuments: texts.map((e) => DocumentNode(texts: [TextNode(value: e)])).toList(),
      pdfs: pdfBase64s,
      documentID: "$currentMessageID",
      stockName: 'letter',
    )
  ]);

  try {
    // await lock();
    String printResXML = await send(xml: req.toXML().replaceAll(artemisWhiteEnter, "\n").replaceAll(artemisWhiteSpace, " "));
    // await unlock();
    PrintResponse printRes = PrintResponse.fromXML(printResXML);
    if (printRes.result.toLowerCase() == "ok") {
      return CuppsCommandResponse(msg: printRes.result, status: true);
    } else {
      return CuppsCommandResponse(msg: printRes.result, status: false);
    }
  } catch (e) {
    return CuppsCommandResponse(msg: "Device $deviceName send Exception: $e", status: false);
  }

  // print(printRes.toXML());
}