gs1qr

package module
v0.0.0-...-4a13882 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2017 License: BSD-3-Clause Imports: 5 Imported by: 0

README

GoDoc

GS1QR is a Go package for generating GS1 QR codes. It extends rsc.io/qr, adding new data encoding schemes. Basic support is available, missing AIs can be added as needed.

TODO

  • generate the list of AIs from the GS1 specification
  • input validation

Documentation

Overview

Package gs1qr encodes GS1 QR codes.

The GS1 specification is at https://www.gs1.org/docs/barcodes/GS1_General_Specifications.pdf. See also https://2016archive.gs1us.org/gs1-us-library/command/core_download/entryid/768/method/attachment

QR code generation is based on Russ Cox' qr package: https://github.com/rsc/qr

Example
list, err := ai.ParseSeq("(01)03453120000011(8200)http://abc.net(10)XYZ(410)9501101020917")
if err != nil {
	fmt.Println(err)
	return
}
el := ConvertElements(list)
fmt.Println(strings.Join(el.Strings(), ""))
Output:

<FNC1>01034531200000118200http://abc.net<GS>10XYZ%4109501101020917

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(list []coding.Encoding, l coding.Level, v coding.Version) ([]byte, error)

Bytes returns, for debugging purposes, a binary representation of the list of QR data encoding schemes at the given error correction level.

func Encode

func Encode(list []coding.Encoding, level coding.Level, minVersion coding.Version) (*qr.Code, *coding.Plan, error)

Encode returns an encoding of the list of QR data encoding schemes at the given error correction level.

Types

type Elem

type Elem struct {
	*ai.Elem
	// contains filtered or unexported fields
}

An Elem is an ai.Elem with additional encoding specific information.

func (*Elem) String

func (e *Elem) String() string

type ElemList

type ElemList []Elem

ElemList is a slice of elements.

func ConvertElements

func ConvertElements(list []ai.Elem) ElemList

ConvertElements initializes a slice of Elem from a slice of ai.Elem.

func (ElemList) Compile

func (list ElemList) Compile() []coding.Encoding

Compile translates a list of elements into a corresponding list of QR data encoding schemes.

func (ElemList) Strings

func (list ElemList) Strings() []string

type FNC1

type FNC1 struct{}

FNC1 defines an QR encoding scheme for the Function Code 1

func (FNC1) Bits

func (s FNC1) Bits(v coding.Version) int

func (FNC1) Check

func (s FNC1) Check() error

func (FNC1) Encode

func (s FNC1) Encode(b *coding.Bits, v coding.Version)

func (FNC1) String

func (s FNC1) String() string

type FNC12nd

type FNC12nd struct{}

FNC12nd defines an QR encoding scheme for the Function Code 1 in second position.

func (FNC12nd) Bits

func (s FNC12nd) Bits(v coding.Version) int

func (FNC12nd) Check

func (s FNC12nd) Check() error

func (FNC12nd) Encode

func (s FNC12nd) Encode(b *coding.Bits, v coding.Version)

func (FNC12nd) String

func (s FNC12nd) String() string

Directories

Path Synopsis
example
gs1qr
This example program reads GS1 elements from stdin and writes an GS1 QR code to ./qr.png.
This example program reads GS1 elements from stdin and writes an GS1 QR code to ./qr.png.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL