Chapter 24. Linear Barcodes (One Dimensional Barcodes)

Table of Contents

24.1. Introduction
24.2. How does linear barcodes work?
24.3. Barcode symbologies
24.3.1. Numerical only barcode symbologies
24.3.2. Alphanumerical barcode symbologies
24.3.3. Which symbology should be used?
24.4. Features
24.4.1. Sample application
24.5. Creating barcodes - quick start
24.6. Error handling
24.7. Generating barcodes on the command line
24.8. Format options for barcodes
24.8.1. Adjusting the encodation process
24.8.2. Selecting output format
24.8.3. Writing barcodes to a file
24.8.4. Hiding the human readable text
24.8.5. Adjusting the module width
24.8.6. Setting vertical or horizontal layout
24.8.7. Adjusting height of bar code
24.8.8. Scaling of bar codes
24.8.9. Add frame around bar code
24.8.10. Examples of adjusting the output
24.9. Short description of supported symbologies
24.9.1. UPC A
24.9.2. UPC E
24.9.3. EAN 8
24.9.4. EAN 13
24.9.5. EAN 128
24.9.6. Industrial 2 of 5
24.9.7. Interleaved 2 of 5
24.9.8. CODE 11 (USD 8)
24.9.9. CODE 39
24.9.10. CODE 39 Extended
24.9.11. CODE 128
24.9.12. CODABAR
24.9.13. Bookland (ISBN)

24.1. Introduction


This module is only available in the pro-version of the library.

With the linear (One-dimensional) barcode extension it is possible to create bar codes using all the commonly accepted symbologies. The resulting bar code can be created as either an image (in PNG or JPEG format) or as a Postscript file ready for printing on high resolution printers.

The bar code extension provides extensive data verification which makes sure that the created barcode follows the official applicable standards.


All generated bar codes (except CODE 11 which have little support in Europe) have been extensively verified using Metrologic CCD-47 handhold scanner.

In order to create a linear barcode the module "jpgraph_barcode.php" must be included.

There are several types of linear barcode even though they all use the same principle. The reason for several different types (or symbologies as it is known) is partly to handle different requirements (for example encoding just numerical data or both numerical and alphabetical data) and partly because they were initially created by different companies to solve similar problems. The library supports most of the common linear barcode. These types of barcode look like what can be usually seen on consumer goods.

The different types of barcodes are often referred to as different symbologies.

Most of the commonly used symbologies has been elevated to ISO/IEC standards. Some barcode which have not yet been accepted as ISO standard are available from AIM ( In USA the organization responsible for issuing retail codes used in barcodes are the Uniform Code Council, (UCC)

While these standards are very comprehensive they are of little interest to end user of the barcode. For an end user the three most important question when selecting a barcode symbology are

  1. What characters can be encoded in this symbology?

  2. How efficient is the symbology, i.e. how large will the barcode be for a given input data string?

    Linear barcodes typically encode alphanumerical strings up to maximum of ~20 characters.


    While many of the barcode symbologies can handle, in theory unlimited, string lengths there are practical limitation to how wide barcode a given reader/scanner can interpret. Most handhold scanners can usually not reliable read a barcode wider than ~10cm.

  3. How strong is the tolerance against physical damage, i.e. how large percentage of the barcode can be destroyed while still be readable by a scanner?

    The tolerance for linear barcode are in general low. If one ore more of the bars (making up the barcode) is unreadable the whole barcode is in practice unreadable. While some barcode symbologies include a check digit this is not enough to re-create damaged data. It is only enough to verify with some confidence that the data is intact, however there is still no guarantee since two errors might, by coincidence, make the check digit correct.

    A common way to strengthen linear barcodes is to make them physically larger/taller.

While linear barcodes is still widely used in legacy applications there are almost no new applications that uses linear barcode due in part to the limitations listed above (poor fault tolerance and low capacity). Most new applications uses either RFID tags or two dimensional barcodes (described in the following chapters) which have much higher data capacity and fault tolerance.