Printing ID Cards

Dear all,

I use ODK collect for the registration of farmers. In my Form I enter information on Name, Area, ID-Number and Photo.

Now I would like to use this information and a mobile ID-Card-Printer to print Farmer-ID-Cards visualizing the collected data directly in the field. Is there any option to print further information (Name, Photo, etc.) with the Zebra QR-Code Printing tool? Can the format-dimensions be adjusted? Does anyone know a mobile ID Card printer which could be connected to ODK?

Thanks for your help and warm regards!

In ye olde days of ODK Clinic, I was able to generate a PDF and send that to a printer on the network and it was super useful.

It looks like it's definitely possible to print from Android these days using CloudPrint, so it's just a matter of seeing who else wants this feature and how best to implement it.

@margaret_wambui would a feature like this be useful to you?

1 Like

I would definitely use this feature. The best part is I get to print many
records at once.
This is a good feature to implement.
Thanks Yaw

1 Like

:printer: We have now picked this up and are planning to add a form field that makes it possible to render and print HTML to any connected printer. Form designers will build HTML strings using the concat function and references to other form fields. They will be able to use any HTML functionality including styling, images, tables, etc. @grzegorz has built a nice prototype already!

QR codes

We are planning to add a custom qrcode element. Any text between the opening and closing qrcode tags would be encoded as a QR code and embedded into the HTML.

We want to make it possible to specify the pixel size of the QR code. Although QR codes must always be square, we are currently thinking we'll have users specify values for standard width and height image attributes so we can pass them through to the img that we generate.

For example, to include values for the first_name and last_name fields separated by a space and display it as a 150x150 square, the following expression would go in calculate:

concat("<qrcode width='150' height='150'>", 
${first_name}, " ", ${last_name}, 

Form designers would be able to specify full HTML including html, body, etc or just a snippet like the one above.

More complex example

Here's an example that includes a QR code with form data, an image, and a summary table:

<qrcode width='150' height='150'>First name: "", ${first_name}, ""Last name: "", ${last_name}, ""Age: "", ${age}, ""Email: "", ${email}, ""Phone number: "", ${phone_number}, ""</qrcode></br>
<img width='150' height='150' src=’”, ${photo}, “’>
<td>First name</td>
<td>"", ${first_name}, ""</td>
<td>Last name</td>
<td>"", ${last_name}, ""</td>
<td>"", ${age}, ""</td>
<td>"", ${email}, ""</td>
<td>Phone number</td>
<td>"", ${phone_number}, ""</td>

User experience

After tapping the Print button, users would see a preview using the standard Android print dialog:

They would have the option to print to any connected printer or save as PDF.

Future enhancements

It's not very fun to write HTML using the concat function. :see_no_evil: One thing we'd like to eventually do is to make it easier to express template strings in which form data should be filled in. This will not only benefit this new feature but also make it easier to write things like instance_name expressions.


  • Does the qrcode custom element seem like a reasonable way of specifying a qr code?
  • Does specifying the width and height of qr codes seem overly confusing if they're always intended to be the same? Is it worth doing something more custom here?
  • We initially thought of also making it possible to generate traditional barcodes but it seems like qr codes are almost always preferable. Is there a good reason to consider barcodes as well?
  • Do you or someone you know have a special-format printer that can be added as an Android printer (e.g. a label printer) that they would be willing to test with?

Being able to generate a QRcode seems like something that could potentially be useful in a bunch of different contexts; eg generating and uploading a QRCode. Have you considered using the regular XLSForm image type [actually, XForm type='binary' binding], with perhaps a suitable calculate using your new qrcode(<string>) function that generates binary image data?

Generating a QRcode image inside HTML with a special new element feels a bit odd/non-orthogonal wrt XForms. :thinking: Although in this specific case it would serve the purpose.

We had not considered that! I agree with you that QR codes can be used in a lot of different ways. I wonder, though, whether users would really want to have them be created by Collect if they're going to use them after submission. It seems they'd need to take some other action with submitted data and they could generate the barcodes then. I'd be interested in more concrete examples of use cases if we consider that route.

I agree that it's not very connected to the XForms spec. I think that's ok? It's more like we're using an existing spec (HTML) to do formatting for printing and we're introducing a custom element as part of that.

If we introduced a qrcode function that returns binary instead I imagine we'd need form authors to build up HTML for an img with a data URL for its src? We'd need to introduce base64-encode as well, I think. That feels like it could be more complex.

My mind is running away a little with half baked possibilities for this function and I probably shouldn't, but...

Would this work with a repeat with an unknown count (for each repeat, show the choice/text/image etc) - some kind of loop n times where n = repeat count.

If so, I could produce a fairly bare bones PDF summary report of the submission / part of the submission, if it was needed locally, outside of uploading and other systems producing that report.

I'm not convinced this is a good use case for me, but I'm interested in looking at the ability to create a formatted print output further.

This feature addition really looks awesome to me, can you please give some use case instances in places like Nigeria and India especially on health or humanitarian data collection?

I believe this should be possible. This would require for example generating a single row for every repeat that afterwards would be put together and create a table (in HTML). Such a table could be printed. This is a nice example of what we can achieve with this feature so once it is released I will try to provide such a sample form with repeats.

One specific use case we are aiming to support is an offline clinical trial in which samples need to go from a clinic to a lab facility. Two forms will be used: an intake form in the clinic and a sample processing form at the lab. The intake form will be used to print out information about the sample(s) collected including a qrcode. The lab will scan the qr code in the sample processing form. This will make it possible for the sample processing form to use information from the intake form. In analysis, it will also enable linking submissions to the two forms about the same sample.

This is closely related to the work that we are doing with Entities which help represent a person/place/thing across form submissions. In a context with reliable internet, Entities could be used to meet the same need. Later this year it will be possible to link form submissions through Entities within a single device but using a printout as outlined above will continue to be useful for workflows that have multiple steps performed by different people who are all offline.

This functionality is now available in Collect v2024.1. You can find its documentation here.