About Me!

This blog is about my musings and thoughts. I hope you find it useful, at most, and entertaining, at least.

Résumé [PDF]

Other Pages

Quotes

Links

Presence Elsewhere

jim@jimkeener.com

GitHub

BitBucket

An HTML tag for Barcodes

Date: 2013-04-10
Tags: barcode html

I was thinking yesterday, that it’d be nice if HTML supported barcodes. I found one proposal by Max Power (awesome name btw), created in 2010 and recently updated. There are many, many types of symbologies out there, but to be useful only a dozen or so would need to be supported by user agents, with maybe two dozen composing those that a user will ever encounter. In the Examples are all the ones I’ve come in contact with. Some of those may not have public standards available, in which case they couldn’t be included in a public standard.

Why?

It’s kind of pointless to send so much data in the form of an image over the pipe when it could be rendered on the client-side much more efficiently. Also, agents could scale the barcode correctly, instead of having to do image transforms on it.

How would this work?

I would imagine something like a barcode tag that has two parameters, a type and mode. mode would be type-specific data. The User-Agent would then treat what is between the open and close tags verbatim and generate a barcode from that, including \r\n, just like a pre tag.

<barcode type="QR" mode="H">Hello</barcode>

would render this: !/img/hello-qr.png!. Here mode="H" is used to tell the encoder to use a high level of error correction. I’d imagine that the size, color, margins, padding, &c could be controlled with CSS.

Examples

Symbology HTML Output
QR <barcode type="qr" mode="H">Hello</barcode>
Code 128b <barcode type="code128b">Hello</barcode>
Data Matrix <barcode type="datamatrix">Hello</barcode>
PDF-417 <barcode type="pdf417">Hello</barcode>
Maxi <barcode type="maxi">Hello</barcode>
Aztec <barcode type="aztec">Hello</barcode>
UPC-A <barcode type="upca">123456</barcode>
Planet <barcode type="planet">123456</barcode>

Examples I’ll add

Usefule sites

Barcode Generator

GNU Barcode GNU Barcode is a tool to convert text strings to printed bars. It supports a variety of standard codes to represent the textual strings and creates postscript output. (Ubuntu package barcode)

zbar A command-line barcode reader (Ubuntu package zbar-tools)

zxing Multi-format 1D/2D barcode image processing library with clients for Android, Java

qrencode Qrencode is a utility software using libqrencode to encode string data in a QR Code and save as a PNG image. (Ubuntu package qrencode)

The Barcode Book I found this ont eh clearance rack of Half-Price books and found it to be a good reference.