UPC Barcode Generator

Here is a quick UPC (Universal Product Code) barcode generator.

There are already many free barcode generators available. This one is not touted to be superior in any way although it does generate the smallest SVG output of the free online tools found so far. See the comparison table below.

This side-project was used as a demonstration platform for developing an SVG generator library. The SVG generator will be incorporated in many of the existing projects to provide the capability of saving images as SVG files in addition to the several raster formats already provided.

The advantages of SVG over raster formats are:

  • considerably smaller file size -- on the order of 1/50th the size of conventional raster files
  • accurate, sharp image no matter the resizing applied afterwards. You can use any browser, its built-in print dialog window, or other viewing and printing utilities to view and scale the image as needed
  • image can be changed using an SVG editor tool or by hand with any text editor. Alterations include for example: background colour, adding or removing items in the image, copying portions of the image to be incorporated elsewhere, etc.
  • image file is in plain text format. It can be embedded / incorporated easily into web pages or included with other text such as emails (image may be rendered graphically or the SVG code may be sent as readable code)

NOTE: SVG is a predominantly vector oriented rendering code. It is not capable of efficient, direct representation of continuous-tone images such as photographs or computer generated continuous-tone data. With the exception of polygonal area fills with linear colour gradient.

As was mentioned earlier the SVG size is smaller than that generated by rival tools. Below is a table showing the file sizes made by the various free tools found.

All tools were tasked to produce the identical barcode number: "012459363636". All comments were removed for 'output' size. Headers and superfluous code were removed using an online SVG optimizer tool to obtain the 'minified' size.

Revised 1 Aug 2020