Skip to content

Widget passing variables #883

Closed
Closed

Description

@itg-assistant

Tim Larson asked 2017-06-05 22:49:41 UTC

I have created a widget to print on a local printer using qz

https://qz.io/

I can get the sample to print but I can't get the passed data to print it keeps saying undefined. How do I get the printData variable down to the data section?
this.onPrint = function(printData){

   qz.websocket.connect().then(function() {
       return qz.printers.find("Pin Printer")               // Pass the printer name into the next Promise
}).then(function(printer) {
  var config = qz.configs.create(printer);       // Create a default config for the found printer
  var data = ['^XA^FO50,50^ADN,36,20^FDRAW ZPL EXAMPLE^FS^XZ'];   // Raw ZPL
  return qz.print(config, data);
}).catch(function(e) { console.error(e); });

}

Thanks,
Tim Larson

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-06-06 13:43:02 UTC

    From the server you call widget.Call("onPrint", dataToPrint)?

    In the posted snippet, the line that prints is qx.print(config, data) is the line that prints and "data" is the data? IIUC, printData has to be assigned to data?

    If you post a small sample I may be able to understand better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    GeneralQuestions, how-tos and everything else.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions