GS1-128
Unterstützt IronBarcode die GS1 UCC/EAN-128-Symbologie?
Barcodes mit GS1 werden genau erkannt und dekodiert. Das Problem liegt jedoch im aktuellen Fehlen von Klammern im angezeigten Barcode-Wert.
Bei Verwendung von GS1-128 gibt IronBarcode aktuell Folgendes aus: 01950123456789033103000123 (was als Code 128 Barcode mit GS1-Signatur erkannt wird). Der gewünschte Wert, der auf dem Bild angezeigt werden soll, wäre: 01950123456789033103000123. Der Barcode-Scanner gibt jedoch (01)95012345678903(3103)000123 aus, wobei der Barcode-Typ als Code128 erkannt wird.
Zum Generieren eines GS1-128-Barcodes verwenden Sie den folgenden Code:
using IronBarCode;
class BarcodeExample
{
static void Main()
{
// Create a GS1-128 barcode using the specified value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);
// Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode();
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
using IronBarCode;
class BarcodeExample
{
static void Main()
{
// Create a GS1-128 barcode using the specified value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);
// Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode();
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
Imports IronBarCode
Friend Class BarcodeExample
Shared Sub Main()
' Create a GS1-128 barcode using the specified value
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1)
' Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode()
' Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png")
End Sub
End Class
Ausgabe-Barcode

Der obige Code erzeugt einen GS1-128-Barcode mit einem Standardteiler. Wenn Sie zusätzliche Trennzeichen hinzufügen möchten, können Sie das Unicode-Trennzeichen \u00f1 einfügen. Beachten Sie jedoch, dass bei Verwendung der Methode AddBarcodeValueTextBelowBarcode das Unicode-Zeichen ñ (Code 0x00F1) angezeigt wird. Um diese Einschränkung zu überwinden, besteht ein alternativer Ansatz darin, die Zeichenkette zu manipulieren und den geänderten Wert an die Methode AddAnnotationTextBelowBarcode zu übergeben. Auf diese Weise können Sie die gewünschte Anzeige des Barcode-Wertes ohne das ñ-Zeichen erreichen.
using IronBarCode;
class BarcodeExampleWithAnnotation
{
static void Main()
{
// Original barcode value
string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";
// Remove unwanted unicode characters for display purposes
string trimmedString = barcodeValue.Replace("\u00f1", "");
// Create a GS1-128 barcode using the original value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);
// Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString);
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
using IronBarCode;
class BarcodeExampleWithAnnotation
{
static void Main()
{
// Original barcode value
string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";
// Remove unwanted unicode characters for display purposes
string trimmedString = barcodeValue.Replace("\u00f1", "");
// Create a GS1-128 barcode using the original value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);
// Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString);
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
Imports IronBarCode
Friend Class BarcodeExampleWithAnnotation
Shared Sub Main()
' Original barcode value
Dim barcodeValue As String = "0195012345678903310300012300" & ChrW(&H00f1).ToString() & "0000000123300000" & ChrW(&H00f1).ToString() & "0000012312300000"
' Remove unwanted unicode characters for display purposes
Dim trimmedString As String = barcodeValue.Replace(ChrW(&H00f1).ToString(), "")
' Create a GS1-128 barcode using the original value
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1)
' Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString)
' Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png")
End Sub
End Class
Ausgabe-Barcode

Beim Scannen des Barcodes wird die Ausgabe (01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000 sein, und der Barcode-Typ wird als GS1Code128 erkannt.
GS1-128-Kodierung analysieren
IronBarcode kann auch die physikalische Codierung eines GS1-128-Barcodes analysieren und zeigt an, welche Code-128-Zeichensätze (A, B oder C) für jedes Datensegment verwendet werden. Verwenden Sie die Methode Code128GS1Parser.ParseWithEncoding, um eine GS1-Zeichenkette einschließlich Kodierungsanalyse zu analysieren.
using IronBarCode;
// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary); // "C"
Console.WriteLine(gs1Result.HasEncodingInfo); // true
using IronBarCode;
// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary); // "C"
Console.WriteLine(gs1Result.HasEncodingInfo); // true
Imports IronBarCode
' GS1-128 with encoding analysis
Dim gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003")
Console.WriteLine(gs1Result.CharacterSetSummary) ' "C"
Console.WriteLine(gs1Result.HasEncodingInfo) ' True
Da GS1-128-Daten hauptsächlich numerisch sind, verwendet der Encoder Code C für maximale Kompaktheit. Die Eigenschaft HasEncodingInfo bestätigt, dass eine Kodierungsanalyse für das Ergebnis verfügbar ist.

