ExBarcode

Hex.pmDocsLicense

Pure Elixir barcode encoding — Code 128 (full ASCII). No external dependencies. Returns bar patterns as lists of module widths suitable for any renderer (PDF, SVG, Canvas, etc.).

Part of the ExPDF umbrella.

Installation

def deps do
  [
    {:ex_barcode, "~> 0.1"}
  ]
end

Usage

Standard encoding

{:ok, bars} = ExBarcode.encode("Hello-123")
# Returns alternating bar/space module widths

Shaped encoding (creative barcodes)

{:ok, result} = ExBarcode.encode_shaped("SPOT2NITE", shape: :rv)
result.bars          # positioned bars with individual heights
result.decorations   # solid shapes (wheels, windows, etc.)

Returns an ExBarcode.Shape.Result with normalized 0.0–1.0 coordinates. Any renderer scales to desired size.

Available shapes: :rv, :camper, :city, :wave, :diamond, :hill

License

MIT. See LICENSE.md.