Hi Sami,
Thanks for considering Aspose.
Please see the sample code snippet below that generates the barcode for an arabic (UTF-8) text. And then recognizes the codetext.
Please change the UTF-8 text to your own. The method will return the recognized codetext. You can set in some UI control e.g. textbox that supports UTF-8 characters display support.
public
string GenerateAndRecognizeUTFBarCode()
{
Bitmap imgBarcode = null;
// set license
License license = new License();
license.SetLicense(
"c:\\Aspose.Total.lic");
try
{
// generate the barcode
BarCodeBuilder objBarCodeBuilder = new BarCodeBuilder();
objBarCodeBuilder.SymbologyType = Aspose.BarCode.
Symbology.MacroPdf417;
// set the codetext by converting it into unicode byte array
byte[] byteArray = Encoding.Unicode.GetBytes("منحة");
objBarCodeBuilder.SetCodeText(byteArray);
imgBarcode = objBarCodeBuilder.GenerateBarCodeImage();
imgBarcode.Save(
"c:\\barcodes.png");
// recognize the above barcode
BarCodeReader reader = new BarCodeReader("c:\\barcodes.png");
reader.BarCodeReadType =
BarCodeReadType.MacroPdf417;
BarCodeInfo[] info = reader.Read();
if (info.Length > 0)
{
Encoding unicode = Encoding.Unicode;
// get the characters array from the bytes
char[] unicodeChars = new char[unicode.GetCharCount(info[0].CodeBytes, 0, info[0].CodeBytes.Length)];
unicode.GetChars(info[0].CodeBytes, 0, info[0].CodeBytes.Length, unicodeChars, 0);
// build unicode string
string strCodeText = new string(unicodeChars);
System.
Console.WriteLine(strCodeText);
return strCodeText;
}
return "no barcode found";
}
catch (Exception ex)
{
return ex.Message;
}
}
Best Regards,
Saqib Razzaq
Support Developer
Aspose Guangzhou Team