From a8e67c5d16f5f4de67a62c2dd28d48f9e52216c6 Mon Sep 17 00:00:00 2001 From: zhaori96 Date: Fri, 2 Aug 2024 12:30:54 -0300 Subject: [PATCH] Add EncodeWithChecksum color overload --- code128/encode.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code128/encode.go b/code128/encode.go index 3e1b646..9a101b6 100644 --- a/code128/encode.go +++ b/code128/encode.go @@ -189,6 +189,10 @@ func Encode(content string) (barcode.BarcodeIntCS, error) { } func EncodeWithoutChecksum(content string) (barcode.Barcode, error) { + return EncodeWithoutChecksumWithColor(content, barcode.ColorScheme16) +} + +func EncodeWithoutChecksumWithColor(content string, color barcode.ColorScheme) (barcode.Barcode, error) { contentRunes := strToRunes(content) if len(contentRunes) <= 0 || len(contentRunes) > 80 { return nil, fmt.Errorf("content length should be between 1 and 80 runes but got %d", len(contentRunes)) @@ -204,5 +208,5 @@ func EncodeWithoutChecksum(content string) (barcode.Barcode, error) { result.AddBit(encodingTable[idx]...) } result.AddBit(encodingTable[stopSymbol]...) - return utils.New1DCode(barcode.TypeCode128, content, result), nil + return utils.New1DCodeWithColor(barcode.TypeCode128, content, result, color), nil }