2023-09-01 20:50:47 +01:00
|
|
|
package generation
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/boombuler/barcode"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Generate(parameters Parameters) (barcode.Barcode, error) {
|
|
|
|
var barcode_content barcode.Barcode
|
|
|
|
var err error
|
|
|
|
|
|
|
|
switch parameters.Format {
|
|
|
|
case Aztec:
|
|
|
|
barcode_content, err = generateAztec(parameters)
|
|
|
|
case Codabar:
|
|
|
|
barcode_content, err = generateCodabar(parameters)
|
|
|
|
case Code93:
|
|
|
|
barcode_content, err = generateCode93(parameters)
|
|
|
|
case Code128:
|
|
|
|
barcode_content, err = generateCode128(parameters)
|
|
|
|
case QR:
|
|
|
|
barcode_content, err = generateQr(parameters)
|
|
|
|
case Datamatrix:
|
|
|
|
barcode_content, err = generateDatamatrix(parameters)
|
2023-09-01 22:14:11 +01:00
|
|
|
case PDF417:
|
|
|
|
barcode_content, err = generatePDF417(parameters)
|
|
|
|
case TwoOfFiveInterleaved:
|
|
|
|
barcode_content, err = generate2of5Interleaved(parameters)
|
|
|
|
case TwoOfFive:
|
|
|
|
barcode_content, err = generate2of5(parameters)
|
2023-09-01 20:50:47 +01:00
|
|
|
default:
|
|
|
|
fmt.Println("Unsupported barcode type: ", parameters.Format)
|
|
|
|
}
|
|
|
|
|
2023-09-01 21:51:30 +01:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Generation Error: ", err)
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
fmt.Println("Barcode Generated")
|
2023-09-01 20:50:47 +01:00
|
|
|
return barcode_content, err
|
|
|
|
}
|