Add Code39

This commit is contained in:
Fred Boniface 2023-09-04 12:05:16 +01:00
parent 073737d0e7
commit 54fa0d34ad
4 changed files with 28 additions and 7 deletions

18
generation/code39.go Normal file
View File

@ -0,0 +1,18 @@
package generation
import (
"fmt"
"github.com/boombuler/barcode"
"github.com/boombuler/barcode/code39"
)
func generateCode39(parameters Parameters) (barcode.Barcode, error) {
GeneratedBarcode, err := code39.Encode(parameters.Content, true, true)
if err != nil {
fmt.Println("Error creating Barcode", err)
}
strippedBarcode := GeneratedBarcode.(barcode.Barcode)
return strippedBarcode, err
}

View File

@ -29,6 +29,8 @@ func Generate(parameters Parameters) (barcode.Barcode, error) {
barcode_content, err = generate2of5Interleaved(parameters) barcode_content, err = generate2of5Interleaved(parameters)
case TwoOfFive: case TwoOfFive:
barcode_content, err = generate2of5(parameters) barcode_content, err = generate2of5(parameters)
case Code39:
barcode_content, err = generateCode39(parameters)
default: default:
fmt.Println("Unsupported barcode type: ", parameters.Format) fmt.Println("Unsupported barcode type: ", parameters.Format)
} }

View File

@ -12,6 +12,7 @@ const (
PDF417 BarcodeType = "pdf417" PDF417 BarcodeType = "pdf417"
TwoOfFive BarcodeType = "2of5" TwoOfFive BarcodeType = "2of5"
TwoOfFiveInterleaved BarcodeType = "2of5interleaved" TwoOfFiveInterleaved BarcodeType = "2of5interleaved"
Code39 BarcodeType = "code39"
) )
type ECCLevel int type ECCLevel int

View File

@ -41,13 +41,13 @@ var FormatRules = map[string]rule{
divisible: 1, divisible: 1,
}, },
/* "code39": { "code39": {
minLength: 1, minLength: 1,
maxLength: 80, maxLength: 80,
charset: *CODE39, charset: *ASCII,
divisible: 1, divisible: 1,
}, },
*/
"code93": { "code93": {
minLength: 1, minLength: 1,
maxLength: 80, maxLength: 80,