QR code insect labels from Arctos using free software

I wanted to be able to print small QR codes readable by our Motorla DS6708 scanner directly onto laser-printed insect specimen labels to use with Arctos‘ object tracking system, preferably using free software.  In case this would be useful to anyone else, this post describes my methods.

All of the files mentioned below, including pdf output, are available in a zipped archive here.  Note that most or all of the links to Arctos pages included below will not work for anyone who is not an Arctos operator having the appropriate roles.


  1. Choose specimens and get comma-separated list of their catalog numbers.  A starting container barcode value will also be needed.
  2. Get flat table containing label data from Arctos.
  3. Run label data through label-generating R script.
  4. Print the labels, check them, and label the specimens.
  5. Create the containers in Arctos.
  6. Move the specimens to the containers in Arctos via the automatically-generated bulkloading file.  Scan the pins into their parent contaiers, etc.

1. Choose specimens and container barcode label start.

A comma-separated list can easily be made using MS Excel, a text editor, etc.  Today I have a list of 330 specimen catalog numbers (most omitted):



My last container label/barcode was KNWRC1225, so today I will be starting with KNWRC1226.

2. Get the label data.

I submit the query below to Arctos via Reports > Write SQL, selecting the CSV format for the result set.

select * from flat where cat_num in (

I download the CSV to the folder in which I want to make the labels and rename it something like 2013-03-08-1012_label_data.csv.

3. Run label data through label-generating R script.

Below is the script controlling the generation of the labels.

working.directory <- "J:/mattbowser/labels"
input.file <- "2013-03-08-1012_label_data.csv"
 barcode.start=1226, prefix="KNWRC"

Running this script in R generates the labels, but a lot goes on behind the scenes, requiring some free software.

  • R – reshapes the data and calls the other software.
  • XeTeX – does the typesetting.
  • qrcode – generates QR code images in png format.
  • ImageMagick – converts png images to bmp format required by potrace.
  • potrace – vectorizes the bmp images for optimal printing.

The script above calls the function make.labels defined in the text file f_makelabels_2013-03-08-1053.R.  This can take a while.

make.labels calls the function make.qrcodes defined in the file f_makeqrcodes_2012-09-26-1348.R to make the QR codes.  Since I lack authorization to install programs on my workplace computer, the function needs the locations of the executables (qrcode, ImageMagick, and potrace).

The script writes a TeX file, 2013-03-08-1012_label_data.tex,  based on the input data.  It then runs this TeX file through XeLaTeX, generating the labels in pdf format.  The TeX file calls for two customized TrueType fonts to make these labels, DroidSansDotted90.ttf and DroidSansDotted-Bold90.ttf.

Command line output:

[1] "working directory: J:/mattbowser/labels"
[1] "input: 2013-03-08-1012_label_data.csv"
[1] "label type: pin"
[1] "barcode series: KNWRC1226-KNWRC1555"
[1] "output TeX file: 2013-03-08-1012_label_data.tex"
[1] "command: xelatex 2013-03-08-1012_label_data.tex"

The labels can now be printed.

4. Label specimens, etc.

Check over the labels carefully before proceeding.  If they are satisfactory, the labels can now be put onto the pins.

5. Create the containers in Arctos.

A container series matching that of the pdf needs to be made in Arctos via Manage Data > Object Tracking > Create Container Series.  The main R script spits out the start and stop label/barcode values on the command line for this purpose.

6. Move the specimens to the containers in Arctos.

make.labels generates a file for this purpose, 2013-03-08-1012_label_data_upload.csv.  Upload this file via Enter Data > Batch Tools > Parts>>Containers. Now these pins can be scanned into their parent containers