Generate and Read Royal Mail Mailmark 2D Barcode using C#

The Royal Mail Mailmark 2D barcode is a machine-readable complex barcode used in letters. It provides information about mail tracking and delivery status. It may also include additional information, such as the delivery schedule and reporting statistics. In this article, we will learn how to generate and read the Royal Mail Mailmark 2D barcode using C#.

The following topics shall be covered in this article:

  1. C# API to Generate and Read Royal Mail Mailmark 2D Barcode
  2. What is Royal Barcode
  3. Types of Royal Mail Mailmark 2D Barcode
  4. Generate Royal Mail Mailmark 2D Barcode
  5. Read Royal Mail Mailmark 2D Barcode

C# API to Generate and Read Royal Mail Mailmark 2D Barcode

For generating and reading Royal Mail Mailmark 2D barcode, we will be using the Aspose.BarCode for .NET API. Using the API, we can generate and recognize a wide range of 1D & 2D barcode types.

Please either download the DLL of the API or install it using NuGet.

PM> Install-Package Aspose.BarCode

What is Royal Barcode

The Royal Mail barcode is a Complex Mail Data Mark (CMDM) barcode. It was developed by the UK Postal System to automate mail sorting and tracking. It has the specified format of a Data Matrix type ECC200 code complying with the international standard. It is also called the Royal Mail 4-State Customer Code (RM4SCC).

Types of Royal Mail Mailmark 2D Barcode

There are three types of 2D Complex Mail Data Mark barcodes:

  • Type 7:
    • Letters
    • Barcode Size: 24 × 24 modules
    • Physical Size: 12 × 12 mm
    • Total Character Count: 51 Characters
    • Customer Use: 6 spare spaces
Mailmark2DType7
  • Type 9:
    • Large Letters, including poly wrap
      letters.
    • Barcode Size: 32 × 32 modules
    • Physical Size: 16 × 16 mm
    • Total Character Count: 90 Characters
    • Customer Use: >25 but a max of 45 spare spaces
Mailmark2DType9
  • Type 29:
    • Large Letters, including poly wrap letters.
    • Barcode Size: 16 × 48 modules
    • Physical Size: 8 × 24 mm
    • Total Character Count: 70 Characters
    • Total Character Count: need 6-25 customer characters
Mailmark2DType29

Generate Royal Mail Mailmark 2D Barcode using C#

We can generate Royal Mail Mailmark 2D barcode by following the steps given below:

  1. Firstly, create an instance of the Mailmark2DCodetext class.
  2. Next, set various properties such as UPUCountryID, VersionID, Class, ItemID, etc.
  3. Then, specify Mailmark2DType as Type_7, Type_9, or Type_29.
  4. Next, create an instance of the ComplexBarcodeGenerator class with Mailmark2DCodetext object as an argument.
  5. After that, set the barcode dimensions.
  6. Finally, call the Save method to save the barcode image on the local disk.

The following code example demonstrates how to generate a Mailmark 2D barcode of type 7 using C#.

Read Royal Mail Mailmark 2D Barcode using C#

We can read Royal Mail Mailmark 2D barcode by following the steps given below:

  1. Firstly, create an instance of the BarCodeReader class.
  2. Next, provide the input barcode image path and the DecodeType.
  3. Then, get the BarCodeResult by calling the ReadBarCodes() method.
  4. After that, decode the barcode using the TryDecodeMailmark2D() method.
  5. Finally, read decoded properties of the Mailmark2DCodetext object.

The following code example demonstrates how to read a Mailmark 2D barcode using C#.

UPUCountryID:JGB
InformationTypeID:0
VersionID:1
Class:1
SupplyChainID:123
ItemID:1234
DestinationPostCodeAndDPS:QWE1
RTSFlag:0
ReturnToSenderPostCode:QWE2
CustomerContent:CUSTOM DATA

Get a Free License

You can get a free temporary license to try the library without evaluation limitations.

Conclusion

In this article, we have learned how to generate Royal Mail Mailmark 2D barcode and save barcode images on the disk. We have also seen how to read the generated Mailmark 2D barcode programmatically. Besides, you can learn more about Aspose.BarCode for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on our free support forum.

See Also