barcodes/generation/generate.go

43 lines
1.0 KiB
Go

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)
case PDF417:
barcode_content, err = generatePDF417(parameters)
case TwoOfFiveInterleaved:
barcode_content, err = generate2of5Interleaved(parameters)
case TwoOfFive:
barcode_content, err = generate2of5(parameters)
default:
fmt.Println("Unsupported barcode type: ", parameters.Format)
}
if err != nil {
fmt.Println("Generation Error: ", err)
return nil, err
}
fmt.Println("Barcode Generated")
return barcode_content, err
}