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.
- Choose specimens and get comma-separated list of their catalog numbers. A starting container barcode value will also be needed.
- Get flat table containing label data from Arctos.
- Run label data through label-generating R script.
- Print the labels, check them, and label the specimens.
- Create the containers in Arctos.
- 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 (
and COLLECTION = 'KNWR ENTO'
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"
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:
 "working directory: J:/mattbowser/labels"
 "input: 2013-03-08-1012_label_data.csv"
 "label type: pin"
 "barcode series: KNWRC1226-KNWRC1555"
 "output TeX file: 2013-03-08-1012_label_data.tex"
 "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…