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.
Beim Verwenden von GS1-128 gibt IronBarcode derzeit aus: 01950123456789033103000123 (was als Code-128-Barcode mit GS1-Signatur erkannt wird). Der gewünschte Wert, der im Bildausgang angezeigt werden soll, wäre: 01950123456789033103000123. Der Barcode-Scanner wird jedoch (01)95012345678903(3103)000123 mit einer Erkennung des Barcode-Typs als Code128 ausgeben.
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");
}
}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 ClassImports 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 ClassAusgabe-Barcode

Der obige Code erzeugt einen GS1-128-Barcode mit einem Standardteiler. Wenn Sie zusätzliche Trennzeichen hinzufügen möchten, können Sie den Unicode-Trenner \u00f1 einfügen. Beachten Sie jedoch, dass beim Verwenden der AddBarcodeValueTextBelowBarcode Methode das Unicode-Zeichen ñ (Code 0x00F1) angezeigt wird. Um diese Einschränkung zu überwinden, ist ein alternativer Ansatz, den String zu manipulieren und den modifizierten Wert an die AddAnnotationTextBelowBarcode Methode 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
Class BarcodeExampleWithAnnotation
Shared Sub Main()
' Original barcode value
Dim barcodeValue As String = "0195012345678903310300012300" & ChrW(&HF1) & "000000123300000" & ChrW(&HF1) & "0000012312300000"
' Remove unwanted unicode characters for display purposes
Dim trimmedString As String = barcodeValue.Replace(ChrW(&HF1), "")
' 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 ClassImports IronBarCode
Class BarcodeExampleWithAnnotation
Shared Sub Main()
' Original barcode value
Dim barcodeValue As String = "0195012345678903310300012300" & ChrW(&HF1) & "000000123300000" & ChrW(&HF1) & "0000012312300000"
' Remove unwanted unicode characters for display purposes
Dim trimmedString As String = barcodeValue.Replace(ChrW(&HF1), "")
' 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 ClassAusgabe-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 Code128GS1Parser.ParseWithEncoding Methode, um einen GS1-String mit eingeschlossener Kodierungsanalyse zu parsen.
using IronBarCode;
// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary); // "C"
Console.WriteLine(gs1Result.HasEncodingInfo); // trueusing IronBarCode;
// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary); // "C"
Console.WriteLine(gs1Result.HasEncodingInfo); // trueImports IronBarCode
' GS1-128 with encoding analysis
Dim gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003")
Console.WriteLine(gs1Result.CharacterSetSummary) ' "C"
Console.WriteLine(gs1Result.HasEncodingInfo) ' TrueImports IronBarCode
' GS1-128 with encoding analysis
Dim gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003")
Console.WriteLine(gs1Result.CharacterSetSummary) ' "C"
Console.WriteLine(gs1Result.HasEncodingInfo) ' TrueDa GS1-128-Daten hauptsächlich numerisch sind, verwendet der Encoder Code C für maximale Kompaktheit. Die HasEncodingInfo Eigenschaft bestätigt, dass die Kodierungsanalyse im Ergebnis verfügbar ist.
Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender Handbücher.