From a1764391c7954b6bf5f49d09d4a5a32924e74dc9 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Tue, 27 Dec 2016 13:46:03 +0100 Subject: Add support for Aztec barcodes (#101) * Add RegisterAztec * Add test for RegisterAztec --- contrib/barcode/barcode.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'contrib/barcode/barcode.go') diff --git a/contrib/barcode/barcode.go b/contrib/barcode/barcode.go index 0649564..63a4908 100644 --- a/contrib/barcode/barcode.go +++ b/contrib/barcode/barcode.go @@ -21,6 +21,7 @@ import ( "bytes" "errors" "github.com/boombuler/barcode" + "github.com/boombuler/barcode/aztec" "github.com/boombuler/barcode/codabar" "github.com/boombuler/barcode/code128" "github.com/boombuler/barcode/code39" @@ -110,6 +111,15 @@ func Register(bcode barcode.Barcode) string { return key } +// RegisterAztec registers a barcode of type Aztec to the PDF, but not to +// the page. Use Barcode() with the return value to put the barcode on the page. +// code is the string to be encoded. minECCPercent is the error correction percentage. 33 is the default. +// userSpecifiedLayers can be a value between -4 and 32 inclusive. +func RegisterAztec(pdf barcodePdf, code string, minECCPercent int, userSpecifiedLayers int) string { + bcode, err := aztec.Encode([]byte(code), minECCPercent, userSpecifiedLayers) + return registerBarcode(pdf, bcode, err) +} + // RegisterCodabar registers a barcode of type Codabar to the PDF, but not to // the page. Use Barcode() with the return value to put the barcode on the page. func RegisterCodabar(pdf barcodePdf, code string) string { -- cgit v1.2.1-24-ge1ad