Aspose Barcode: ComplexCodetextReader.TryDecodeMailmark2D not decoding any DataMatrixes

Hi, I’m trying to decode a simple Royal Mail data matrix from CodeText like this one:
"JGB 82156A1108ACDFCE30000150101010300922036 LO200137208GB8 BR XX111XXS " or this one:
“JGB 82142A1108924EFFF0000100100245160922009 KB903170547GB60 TN23JT GB XX111XXS”
The mailmarkResult is always null, my code is:

var reader2 = new BarCodeReader(file, DecodeType.AllSupportedTypes);
foreach (BarCodeResult result in reader2.ReadBarCodes())
{
// Decode Mailmark 2D
Mailmark2DCodetext mailmarkResult = ComplexCodetextReader.TryDecodeMailmark2D(result.CodeText);
}

Can you suggest what is wrong with this?

@otaen,

Could you please share your barcode image file, we will check it soon.

Here’s the image: https://drive.google.com/file/d/19HWSf75dbiYSNHx2vywg_9zj3mSsKjW3/view?usp=sharing
There’s nothing wrong with it and Aspose barcode reader reads it properly, just can’t decode.

@otaen,

Thanks for the barcode image.

I did test your scenario/case using your barcode image and found Mailmark2DCodetext is null. But it works fine when simply reading barcode text from the image. See the following sample code that works Ok.
e.g.
Sample code:

var bmp1 = new Bitmap("e:\\test2\\Untitled.png");
using (Aspose.BarCode.BarCodeRecognition.BarCodeReader reader1 = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(bmp1, Aspose.BarCode.BarCodeRecognition.DecodeType.AllSupportedTypes))
{
  Console.WriteLine(reader1.ReadBarCodes().Length);
  foreach (Aspose.BarCode.BarCodeRecognition.BarCodeResult result1 in reader1.ReadBarCodes())
  {
                    // Read symbology type and code text
                    Console.WriteLine(result1.CodeTypeName);
                    Console.WriteLine("Symbology Type: " + result1.CodeType);
                    Console.WriteLine("CodeText: " + result1.CodeText);

                    
  }
} 

output:

DataMatrix
Symbology Type: DataMatrix
CodeText: JGB 82156A1108ACDFCE30000150101010300922036 LO200137208GB8 BR MK403PNS

Does the above code not work for your needs? If not why you want to evaluate via complex barcode reader, please elaborate? We will look into it soon.

Hi, do you understand the difference between reading barcode and decoding one? Reading works fine, decoding does not.
I need the following from mailmarkResult:

// Read properties
Console.WriteLine($“UPUCountryID:{mailmarkResult.UPUCountryID}”);
Console.WriteLine($“InformationTypeID:{mailmarkResult.InformationTypeID}”);
Console.WriteLine($“VersionID:{mailmarkResult.VersionID}”);
Console.WriteLine($“Class:{mailmarkResult.Class}”);
Console.WriteLine($“SupplyChainID:{mailmarkResult.SupplyChainID}”);
Console.WriteLine($“ItemID:{mailmarkResult.ItemID}”);
Console.WriteLine($“DestinationPostCodeAndDPS:{mailmarkResult.DestinationPostCodeAndDPS}”);
Console.WriteLine($“RTSFlag:{mailmarkResult.RTSFlag}”);
Console.WriteLine($“ReturnToSenderPostCode:{mailmarkResult.ReturnToSenderPostCode}”);
Console.WriteLine($“CustomerContent:{mailmarkResult.CustomerContent}”);

@otaen,

Thanks for providing further details.

We were able to reproduce the issue as you mentioned using your sample barcode image. Apparently, the ComplexCodetextReader.TryDecodeMailmark2D does not decode DataMatrix barcodes. I have logged a ticket with an id “BARCODENET-38382” for your issue. We will look into it.

Once we have an update on it, we will let you know here.

Thanks a lot for your help.

@otaen,

You are welcome.

Mailmark-Barcode-definition-document-150221-v1.3.pdf (457.3 KB)

As I can see the encoded CodeText is incorrect and does not fit to “Table 2 – Data definitions common to 2D Mailmark barcodes” from “Mailmark-Barcode-definition-document-150221-v1.3.pdf”.

The encoded CodeText in DataMatrix is:
"JGB 82156A1108ACDFCE30000150101010300922036 LO200137208GB8 BR MK403PNS "

We can try to decode it.
“JGB ”(4, any letters or digits) - UPU Country ID,
“8” (1, defined set letter or digits) - Information Type ID
“2” (1, Currently “1”) - Version ID. !!!First error because version in the last standard specification cannot be different from 1
“1” (1, any letter or digit) – Class
“56A1108” (7, any digits) - Supply Chain ID. !!!Second error, “A” cannot be placed here
“ACDFCE30” (8, any digits) - Item ID. !!! Third error, “ACDFCE” cannot be set as numeric.

There may be other error, but the generated message is incorrect.

Have you generated it by our encoder? If this is right, could you provide the code, because, in this case, the encoder is incorrect and we have to fix it.

This 2D DataMatrix came from a Royal Mail label provided by Royal Mail themselves.
It was from an international parcel. I’ve tried the same thing with a local (UK) parcel and it didn’t work either, here’s the local barcode:
https://drive.google.com/file/d/1O7xbLZrPJwMDKDH9j7m0tyYFk5i3_lwZ/view?usp=sharing

It is definitely not Royal Mail Mailmark. You can see “Table 4 – Position of C40 encodation latch character in 2D Mailmark barcode types when C40 encodation used throughout”. The data looks differently.

This can be other postal barcode type which uses DataMatrix or some internal Royal Mail Mailmark format. We will investigate this, but this barcode cannot be decoded as Mailmark.

Moreover, the “Screenshot 2022-10-05 205706.jpg” has 44x44 modules, but Mailmark has only:
24 x 24 modules
32 x 32 modules
16 x 48 modules

I sent mail to Royal Mail technical support about Untitled.png format. May be this is internal format.

Ok, found. This is not Mailmark this is “Royal Mail International Tracked” and this is different format. Currently we don’t support it.
https://www.royalmail.com/sites/royalmail.com/files/2021-01/int_china_data_solution.pdf

Thanks. What about my last upload: https://drive.google.com/file/d/1O7xbLZrPJwMDKDH9j7m0tyYFk5i3_lwZ/view?usp=sharing
Is this also not mailmark? it’s a local parcel.
And if these are all not mailmark, how can I decode this barcode?

It is not Mailmark, it is one of the Royal Mail barcodes (it has even incorrect barcode size), but we still don’t know format.

You can find specification of this barcode type and we will implement, or we can try to find, but this takes time.

I’ve no way of finding it, unfortunately. These are the labels you just buy normally on Royal Mail website.

We have requested the barcode specification from Royal Mail, but this can take time.

Thanks a lot.

Got answer from Royal Mail technical team (currently unsuccessful)
helpline@royalmailtechnical.com

Q:
Hello.

Could you give me advice which barcode format do the following DataMatrix barcodes have. Thay have somethink like:
"JGB 6202220D1234567890000003742500 1161215161215CRL01 TECHHUB CAMPUS                     EC2A4BX9ZGB EC2A4BX  EC2A4BX"
And this is not 2D Mailmark.

Alexander Gavriluk
Aspose.Barcode developer

A:

Hi Alexsandr,

They both look like postage from shipping platforms, possibly Click and Drop.

The RM48 looks like a standard label design for Business customer. Could be using Click and Drop or similar platform. Th other one looks like a non business Click and Drop postage.
Their barcodes also use prefix JBG similar to Mailmark.

Regards,
Patrick Olgado
Royal Mail Technical Team

Not very useful response indeed.

Yes. I could not find format of the provided DataMatrixes. Maybe I can find it some later, but I am not sure.

@otaen,

We investigated your issue in details.
The provided DataMatrix barcode is recognized but internal data is not Mailmark2D and has unknown format which we could not resolve.

We do not support the provided data formats without specification.