Documentation
¶
Overview ¶
Package barcode provides one-dimensional and two-dimensional barcode generation using github.com/boombuler/barcode. Supported types include Code128, Code39, Code93, Codabar, EAN-13, EAN-8, UPC-A, 2-of-5, PDF417, DataMatrix, and Aztec Code.
Index ¶
- func Aztec(content string, width, height int) (image.Image, error)
- func Codabar(content string, width, height int) (image.Image, error)
- func Code39(content string, width, height int) (image.Image, error)
- func Code93(content string, width, height int) (image.Image, error)
- func Code128(content string, width, height int) (image.Image, error)
- func DataMatrix(content string, width, height int) (image.Image, error)
- func EAN8(content string, width, height int) (image.Image, error)
- func EAN13(content string, width, height int) (image.Image, error)
- func Generate(typ BarcodeType, content string) (image.Image, error)
- func GeneratePNG(typ BarcodeType, content string, width, height int) ([]byte, error)
- func GenerateScaled(typ BarcodeType, content string, width, height int) (image.Image, error)
- func PDF417(content string, width, height int) (image.Image, error)
- func Save(typ BarcodeType, content, path string, width, height int) error
- func TwoOfFive(content string, width, height int) (image.Image, error)
- func UPC_A(content string, width, height int) (image.Image, error)
- type BarcodeType
- type Metadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataMatrix ¶
DataMatrix generates a DataMatrix 2D barcode.
func EAN8 ¶
EAN8 generates an EAN-8 barcode (7 or 8 digits; checksum is auto-calculated if 7 digits are provided).
func EAN13 ¶
EAN13 generates an EAN-13 barcode (12 or 13 digits; checksum is auto-calculated if 12 digits are provided).
func Generate ¶
func Generate(typ BarcodeType, content string) (image.Image, error)
Generate creates a barcode of the specified type from the given content. The returned image is the raw barcode at 1 module per pixel; use Scale or GenerateScaled for a pixel-sized output. Returns an error for invalid content (e.g. wrong length for EAN).
func GeneratePNG ¶
func GeneratePNG(typ BarcodeType, content string, width, height int) ([]byte, error)
GeneratePNG creates a barcode and encodes it as PNG bytes.
func GenerateScaled ¶
GenerateScaled creates a barcode and scales it to the given pixel dimensions. For 1D barcodes, width should be much larger than height.
func Save ¶
func Save(typ BarcodeType, content, path string, width, height int) error
Save generates a barcode and writes it to a PNG file.
Types ¶
type BarcodeType ¶
type BarcodeType string
BarcodeType identifies the barcode symbology.
const ( TypeCode128 BarcodeType = "code128" TypeCode39 BarcodeType = "code39" TypeCode93 BarcodeType = "code93" TypeCodabar BarcodeType = "codabar" TypeEAN13 BarcodeType = "ean13" TypeEAN8 BarcodeType = "ean8" TypeUPCA BarcodeType = "upca" TypeTwoOfFive BarcodeType = "2of5" TypePDF417 BarcodeType = "pdf417" TypeDataMatrix BarcodeType = "datamatrix" TypeAztec BarcodeType = "aztec" )