barcodes-code128-0.1.0: Generate Code 128 barcodes as PDFs

Safe HaskellNone
LanguageHaskell2010

Graphics.Barcode.Code128

Description

A library for generating barcodes in Code 128. Details of the encoding are available at http://en.wikipedia.org/wiki/Code_128. The width of the stripes and the height of the barcode are configurable. Two modes of operation are supported:

  • Constructing a PDF directly in a ByteString, and
  • Constructing an action in HPDF's Draw monad, for composing the barcode with other information in a PDF.

Synopsis

Documentation

data BarcodeConfig Source

Controls the size of the generated barcode. All units are in HPDF's internal sizing.

Constructors

BarcodeConfig 

Fields

height :: Double

The height of the generated barcode

barWidth :: Double

The width of the narrowest possible bar

data Err Source

Errors that can occur while constructing a barcode

Constructors

CantEncode Char

The returned character cannot be encoded in Code 128

Instances

barcodeSize :: BarcodeConfig -> [Char] -> Either Err (Double, Double) Source

Determine the width and height of rendering a particular string as a barcode in a particular configuration.

barcodePDF :: BarcodeConfig -> String -> IO ByteString Source

Generate PDF data containing the barcode for a given string, with the tightest possible bounding box. If the string cannot be encoded in Code 128, an IOError is thrown.

drawBarcode Source

Arguments

:: BarcodeConfig

How to render the barcode

-> String

The string to encode

-> Point

The origin (lower left) of the barcode on the page

-> Either Err (Draw Point) 

Encode a string and construct an action in Draw that will render it as a barcode. The action, if created successfully, will return the opposite corner of the barcode. An error is returned if the string could not be encoded as a Code128 barcode.