Decode FNC Symbols
Contents
[
Hide
]
The GS1 association utilizes FNC symbols to manage decoding for Code 128 and some other barcode types. There are four types of FNC symbols (FNC1-4) among which FNC1 is the most widespread one and is used for GS1 Application Identifier (AI) marking. When the library detects that a barcode does not correspond to any of GS1 types (e.g. Code 128 or GS1 Code 128), the decoder outputs FNC symbols as “<FNC#>”. Such messages can be deleted from the recognition results by setting the StripFNC property to false.
The following code sample shows how to work with FCN symbols while reading a Code 128 barcode demonstrated below.
//create barcode
using (BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code128, "Aspose" + FNC1 + FNC2 + FNC3))
{
gen.Parameters.Barcode.XDimension.Pixels = 2;
gen.Save($"{path}Code128FNC.png", BarCodeImageFormat.Png);
}
//read barcode image with StripFNC set to False
Console.WriteLine("ReadWithStripFNC:");
Console.WriteLine("StripFNC: false");
using (BarCodeReader read = new BarCodeReader($"{path}Code128FNC.png", DecodeType.Code128))
{
read.BarcodeSettings.StripFNC = false;
foreach (BarCodeResult result in read.ReadBarCodes())
{
Console.WriteLine($"CodeType:{result.CodeTypeName}");
Console.WriteLine($"CodeText:{result.CodeText}");
}
}
//read barcode image with StripFNC set to True
Console.WriteLine("StripFNC: true");
using (BarCodeReader read = new BarCodeReader($"{path}Code128FNC.png", DecodeType.Code128))
{
read.BarcodeSettings.StripFNC = true;
foreach (BarCodeResult result in read.ReadBarCodes())
{
Console.WriteLine($"CodeType:{result.CodeTypeName}");
Console.WriteLine($"CodeText:{result.CodeText}");
}
}