Documentation
¶
Overview ¶
Package barcode generates 1D and 2D barcodes that can be rendered directly into a PDF content stream as vector graphics (no images).
Package barcode generates 1D and 2D barcodes and renders them directly into PDF content streams as vector graphics.
Supported formats:
- QR Code (ISO/IEC 18004) — via NewQR and NewQRWithECC
- Code 128 (ISO/IEC 15417) — via NewCode128
- EAN-13 (GS1 General Specifications) — via NewEAN13
Each constructor returns a Barcode holding a 2D module grid. Call Barcode.Draw to render the barcode onto a content.Stream at any position and size. All output is vector (filled rectangles), so barcodes remain sharp at any zoom level.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Barcode ¶
type Barcode struct {
// contains filtered or unexported fields
}
Barcode is a generated barcode ready to be drawn into a PDF.
func NewCode128 ¶ added in v0.6.0
NewCode128 generates a Code 128 barcode from a string. It encodes the full ASCII range (0-127) by selecting code sets A, B, and C automatically, using Code C for runs of digits. Bytes above 127 return an error.
func NewEAN13 ¶ added in v0.6.0
EAN13 generates an EAN-13 barcode from a 13-digit string. If 12 digits are provided, the check digit is computed automatically. Returns an error if the input is not 12 or 13 digits.
func NewQR ¶ added in v0.6.0
QR generates a QR Code barcode from a string. Uses the most efficient encoding mode with error correction level M (15% recovery). Automatically selects the smallest version (1-40) that fits the data.
func NewQRWithECC ¶ added in v0.6.0
NewQRWithECC generates a QR Code barcode with the specified error correction level. Automatically selects the most efficient encoding mode and smallest version (1-40).