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:
- C# API to Generate and Read Royal Mail QR Codes
- What is a Royal Barcode?
- Types of Royal Mail QR Codes
- Generate a Royal Mail QR Code
- Read the Royal Mail QR Code
- Free Learning Resources
C# API to Generate and Read Royal Mail QR Code
For generating and reading Royal Mail QR code, we will be using the Aspose.BarCode for .NET API. Using the API, we can generate and recognize a wide range of 1D and 2D barcode types.
Please either download the DLL of the API or install it using NuGet.
PM> Install-Package Aspose.BarCode
What is a 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 QR Codes
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
- 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 maximum of 45 spare spaces
- 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: We need 6–25 customer characters.
Generate Royal Mail Barcode Stamp in C#
We can generate a Royal Mail barcode stamp by following the steps below:
- Firstly, create an instance of the Mailmark2DCodetext class.
- Next, set various properties such as UPUCountryID, VersionID, Class, ItemID, etc.
- Then, specify the Mailmark2DType as Type_7, Type_9, or Type_29.
- Next, create an instance of the ComplexBarcodeGenerator class with the Mailmark2DCodetext object as an argument.
- After that, set the barcode dimensions.
- 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 QR Code using C#
We can read the Royal Mail QR code by following the steps given below:
- Firstly, create an instance of the BarCodeReader class.
- Next, provide the input barcode image path and the DecodeType.
- Then, get the BarCodeResult by calling the ReadBarCodes() method.
- After that, decode the barcode using the TryDecodeMailmark2D() method.
- Finally, read the decoded properties of the Mailmark2DCodetext object.
The following code example demonstrates how to read a Mailmark QR code 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.
Mailmark 2D Barcode Library - Learning Resources
Besides generating and reading Royal Mail QR codes, you can learn more about various other features of Aspose.BarCode using the resources given below:
Conclusion
In this article, we have learned how to generate a Royal Mail QR code 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.