| Safe Haskell | None | 
|---|---|
| Language | Haskell2010 | 
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'sDrawmonad, for composing the barcode with other information in a PDF. 
- data BarcodeConfig = BarcodeConfig {}
 - data Err = CantEncode Char
 - barcodeSize :: BarcodeConfig -> [Char] -> Either Err (Double, Double)
 - barcodePDF :: BarcodeConfig -> String -> IO ByteString
 - drawBarcode :: BarcodeConfig -> String -> Point -> Either Err (Draw Point)
 
Documentation
data BarcodeConfig Source
Controls the size of the generated barcode. All units are in HPDF's internal sizing.
Constructors
| BarcodeConfig | |
Errors that can occur while constructing a barcode
Constructors
| CantEncode Char | The returned character cannot be encoded in Code 128  | 
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.
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.