Two-dimensional barcodes? What are they? That’s exactly what I thought when I first came across them. I had an idea that there were different barcode standards, but when I think of barcodes I usually think of a series of vertical black lines. Two dimensional barcodes come in different shapes such as squares, dots, and hexagons. They are also referred to as data matrices.
A two-dimensional barcode string for Courier Post labels is much longer than the one-dimensional barcode string. It includes all of the information inside the one-dimensional barcode as well a few additional parameters.
Example of a two-dimensional barcode string:
EC1257122000000824AKL025BS160920102127CPOLTP A4 N 0000010ASHBY Place PUKEKOHE 21200000000
The first two alpha characters identify this as an ECL barcode. It will always be EC.
The next digit determines the address type. A value of “1” indicates a standard or rural address while a value of “2” indicates a PO Box or Private Bag address.
The next 23 alpha-numeric characters represent the one-dimensional barcode string. For information on this, please refer to <add link to one-dimensional barcode blog>.
We then encode the date that the courier label was produced. The date is represented as an eight-digit number. In the example above, the date is encoded as 16092010 (16th September 2010).
We also need to encode the time that the courier label was produced as a four digit value. The example above represents the time as 2127 (9:27 pm).
The next seven alpha characters determine what is called the Service Code related to the product being packaged. The service code takes into account the parcel weight, the destination location, and whether or not an overnight delivery is required. The example above uses CPOLTP as the service type representing a Courier Post Trackpac.
The next three alpha characters represent the envelope size. This is only required if the service code is CPOLTP. The example above uses “A4” as the envelope size for the Trackpac.
Each of the next six alpha characters represents a number of different options…
1. Return Indicator: A code to indicate returns. It can be one of three values: N (normal), R (return), F (freight forward).
2. Signature Required: S (signature required) or blank space (no signature required).
3. Saturday Delivery: W (Saturday delivery) or blank space (no Saturday delivery).
4. Rural Delivery: R (Rural delivery) or blank space (no rural delivery).
5. Dangerous Goods: D (Dangerous goods) or blank space (no dangerous goods).
6. Not Yet Allocated: This can only be a blank space.
The rest of the information in the two-dimensional barcode string represents address data. It is split up as follows:
Street Number: This is encoded using seven numeric digits and is zero-padded to fill available space.
Street Name: This is encoded using 46 alpha characters. No numbers are allowed in this field. It is padded with empty spaces.
Suburb: This is encoded using 18 alpha characters and is padded with empty spaces.
Town/City: This is encoded using 18 alpha characters and is padded with empty spaces.
Post Code: This is encoded using four numeric digits and is zero-padded to fill available space.
DPID: This is a seven digit ID used for Track and Trace services. This value can be filled in with seven zeros if the DPID is not known or is not required.
That’s all the information we require to build the two-dimensional barcode string. Now to actually generate the barcode image using C#, there are a number of two-dimensional barcode libraries on the web which you can use. You will also need to use a two-dimensional barcode scanner to test if the generated image is encoded correctly.