Creating LTO barcodes

At work we use LTO-2 and LTO-3 tape-robots, which use barcodes to identify tapes. However, these barcodes can be very expensive and hard to come by. This made me look for a method to create the barcodes myself.

I’ve put my web-based version on a new page: Barcode Generator

I found Terry Burton’s ‘postscriptbarcode‘. Which is capable of creating the required ‘Type 39’ barcodes.

After mucking about in postscript (which is not something I do with pleasure…) for a while I got a decent working layout/method to create my barcodes. It can be automated even more, but I only need 1 or 2 sheets of barcodes, so I’ll leave this as an exercise for the reader :).

  1. Download ‘postscriptbarcode‘, and extract barcode_with_sample.ps from it
  2. Remove the lines (near the end) between ‘Helvetica findfont’ and ‘showpage’
  3. Replace the lines with the output of genbarcodes.sh (included below)
  4. Preview the file in evince or a viewer of choice
  5. Print the postscript file, preferably on sticker-paper, cut and stick on tapes

The required barcode-lines can be generated with the following simple bash script:

#!/bin/bash

BASE=”100″;
NR=$BASE

for hor in 30 220 410
do
ver=740
while [ $ver -ge 40 ];
do
printf -v FNR “(%06dL3)” $NR
echo “$hor $ver moveto $FNR (includetext height=0.55) code39 barcode”
let ver=$ver-70
let NR=NR+1
done
done

Replace ‘BASE’ with the number where you want to start numbering, it is incremented by 1 for each barcode, and the barcodes are formatted with the number, filled to 6 digits, appended with ‘L3’. The coordinates are for A4 format paper.

The resulting pdf example of the above script.

Be Sociable, Share!

12 thoughts on “Creating LTO barcodes”

  1. Thanks for your post. It really save me some time. Like you I could not believe the price for labels. I am wondering if you happened to solve the problem for cleaning cartridge labels? Also, where did you happen to find your information about the LTO label specification. Thanks.

  2. You can create cleaning labels by preceding the label with CLN, you might need to make some modifications to the script, to get it to make CLN001, CLN002 etc…

    I got the details by trial-and-error

  3. Any chance you can port this info to be Windows based for the rest of us business users?

    ~Q

  4. Technically it’s all postscript and a bit of bash scripting. Should work just as well using Cygwin on windows.

    And if you only need a couple of barcodes I can probably create them for you and send you the pdf/postscript file. Thinking about this… I’ll turn it into a web-based version… Try it.

  5. Very nice, but why don’t you use the portable

    FNR=$(printf “(%06dL3)” $NR)

    instead of the pointless bashism

    printf -v FNR “(%06dL3)” $NR

  6. Doesn’t work 🙁 maybe they changed original file?
    lines generated by code:
    30 740 moveto (000100L3) (includetext height=0.55) code39 barcode
    30 670 moveto (000101L3) (includetext height=0.55) code39 barcode
    30 600 moveto (000102L3) (includetext height=0.55) code39 barcode
    30 530 moveto (000103L3) (includetext height=0.55) code39 barcode
    30 460 moveto (000104L3) (includetext height=0.55) code39 barcode
    30 390 moveto (000105L3) (includetext height=0.55) code39 barcode
    30 320 moveto (000106L3) (includetext height=0.55) code39 barcode
    30 250 moveto (000107L3) (includetext height=0.55) code39 barcode
    30 180 moveto (000108L3) (includetext height=0.55) code39 barcode
    30 110 moveto (000109L3) (includetext height=0.55) code39 barcode
    30 40 moveto (000110L3) (includetext height=0.55) code39 barcode
    220 740 moveto (000111L3) (includetext height=0.55) code39 barcode
    220 670 moveto (000112L3) (includetext height=0.55) code39 barcode
    220 600 moveto (000113L3) (includetext height=0.55) code39 barcode
    220 530 moveto (000114L3) (includetext height=0.55) code39 barcode
    220 460 moveto (000115L3) (includetext height=0.55) code39 barcode
    220 390 moveto (000116L3) (includetext height=0.55) code39 barcode
    220 320 moveto (000117L3) (includetext height=0.55) code39 barcode
    220 250 moveto (000118L3) (includetext height=0.55) code39 barcode
    220 180 moveto (000119L3) (includetext height=0.55) code39 barcode
    220 110 moveto (000120L3) (includetext height=0.55) code39 barcode
    220 40 moveto (000121L3) (includetext height=0.55) code39 barcode
    410 740 moveto (000122L3) (includetext height=0.55) code39 barcode
    410 670 moveto (000123L3) (includetext height=0.55) code39 barcode
    410 600 moveto (000124L3) (includetext height=0.55) code39 barcode
    410 530 moveto (000125L3) (includetext height=0.55) code39 barcode
    410 460 moveto (000126L3) (includetext height=0.55) code39 barcode
    410 390 moveto (000127L3) (includetext height=0.55) code39 barcode
    410 320 moveto (000128L3) (includetext height=0.55) code39 barcode
    410 250 moveto (000129L3) (includetext height=0.55) code39 barcode
    410 180 moveto (000130L3) (includetext height=0.55) code39 barcode
    410 110 moveto (000131L3) (includetext height=0.55) code39 barcode
    410 40 moveto (000132L3) (includetext height=0.55) code39 barcode

    Inserted in a file, ps2pdf said:
    [root@OpenVZ-01 ~]# ps2pdf barcode_with_sample.ps
    ERROR: /undefined in barcode
    Operand stack:

    Execution stack:
    %interp_exit .runexec2 –nostringval– –nostringval– –nostringval– 2 %stopped_push –nostringval– –nostringval– –nostringval– false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop .runexec2 –nostringval– –nostringval– –nostringval– 2 %stopped_push –nostringval–
    Dictionary stack:
    –dict:1120/1686(ro)(G)– –dict:0/20(G)– –dict:138/200(L)–
    Current allocation mode is local
    Current file position is 231183
    ESP Ghostscript 815.02: Unrecoverable error, exit code 1

    I tried original file. It works.

  7. Yes. I’ve deleted barcode word from end of a line and now it works 🙂
    echo “$hor $ver moveto $FNR (includetext height=0.55) code39 ”

  8. So glad I found this page with the step-by-step instructions. Just had a question. If I have a PHP page with a “submit Query” button that asks the user for a starting point, and # of labels, how do you glue the front-end together with this altered barcode_with_sample.ps file? Is it just a matter of connecting the form-submit to the file?

Comments are closed.