Printing Labels with the Printer Widget

The Printer widget can be used to print labels directly from Collect to a Zebra MZ or iMZ label printer.

Two paper labels. One label has a 1D barcode and some text. The other has a QR code and some text.

Requirements

The print widget requires two additional apps to be installed on your device:

Labels contain one or more of the following:

  • 1D Barcode, encoding a number
  • QR Code, encoding text
  • Text

These three components always appear in this order. Their content is specified in the calculation column of the XLSForm, using the concat() function. The three components are included as strings, separated by '<br>', the XML line break tag.

survey
type name label appearance calculation
text printer_widget Printer widget printer:org.opendatakit.sensors.ZebraPrinter concat('123456789','<br>’,'QR CODE','<br>','Text')

To exclude any of the label components, put an empty string in its place. For example, to print only a QR CODE, with no barcode or text:

calculation
concat('','<br>','QR CODE content here','<br>','')

Or, to print only the barcode and text:

calculation
concat('1234567890','<br>','','<br>','Some text.')

Including data from previous questions

Typically, labels are used to print data from previous questions.

For example, you might print a label with the name of the survey participant:

type name label appearance calculation
text full_name Participant Name    
text print_name_label Print Name Label printer:org.opendatakit.sensors.ZebraPrinter concat('','<br>','${full_name}',<br>,'${full_name}')

Note

The printer widget is used whenever a text field has an appearance attribute that begins with printer. The full form for the appearance attribute is printer:{intentname}, where {intentname} identifies the printer driver.

By copying and modifying the ODK Zebra Printer Driver source code, and then specifying the intent name for that new driver, you can create your own customized label formats without needing to also modify Collect.