barcode

draw

Types

Barcode = object
  width: int
Bars = object
  drawBar*: bool
  width*: int
  height*: int
  positionVertical*: int
BarArray = object
  code*: string
  maxWidth*: int
  maxHeight*: int
  bars*: seq[Bars]

Procs

proc getBarcodeData(code: string; tpye: int): BarArray {...}{.raises: [Exception, OSError],
    tags: [RootEffect].}
proc barcode_code39(code: string; extended: bool = false; checksum: bool = false): BarArray {...}{.
    raises: [Exception, OSError, ValueError, KeyError], tags: [RootEffect].}

CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9. General-purpose code in very wide use world-wide

code:string = code to represent. extended: bool = if true uses the extended mode. checksum: bool = if true add a checksum to the code.

return: array barcode representation.

proc encode_code39_ext(code: string): string {...}{.raises: [OSError, KeyError], tags: [].}

Encode a string to be used for CODE 39 Extended mode.

code:string = code to represent.

return: string encoded string.

proc barcode_code93(code: string): BarArray {...}{.
    raises: [OSError, KeyError, Exception, ValueError], tags: [RootEffect].}

CODE 93 - USS-93 Compact code similar to Code 39

code:string = code to represent.

return: array barcode representation.

proc barcode_s25(code: string; checksum: bool = false): BarArray {...}{.
    raises: [Exception, OSError, KeyError], tags: [RootEffect].}

Standard 2 of 5 barcodes. Used in airline ticket marking, photofinishing Contains digits (0 to 9) and encodes the data only in the width of bars.

code:string = code to represent checksum:bool = if checsum should be added

return = array barcode representation

proc barcode_i25(code: string; checksum: bool = false): BarArray {...}{.
    raises: [Exception, OSError, KeyError, ValueError], tags: [RootEffect].}

Interleaved 2 of 5 barcodes. Compact numeric code, widely used in industry, air cargo Contains digits (0 to 9) and encodes the data in the width of both bars and spaces.

code:string = code to represent checksum:bool = if checsum should be added

return = array barcode representation

proc barcode_c128(code: string; tpye: string = ""): BarArray {...}{.
    raises: [KeyError, OSError, RegexError, Exception, ValueError], tags: [RootEffect].}

C128 barcodes. Very capable code, excellent density, high reliability; in very wide use world-wide

code:string = code to represent. type:string = barcode type: A, B, C or empty for automatic switch (AUTO mode)

return = array barcode representation.

proc barcode_eanupc(code: string; len: int = 13): BarArray {...}{.
    raises: [ValueError, OSError, KeyError], tags: [].}

EAN13 and UPC-A barcodes. EAN13: European Article Numbering international retail product code UPC-A: Universal product code seen on almost all retail products in the USA and Canada UPC-E: Short version of UPC symbol

code:string = code to represent. len:int = barcode type: 6 = UPC-E, 8 = EAN8, 13 = EAN13, 12 = UPC-A

return = array barcode representation.

proc barcode_eanext(code: string; len: int = 5): BarArray {...}{.
    raises: [OSError, ValueError, KeyError], tags: [].}

UPC-Based Extensions 2-Digit Ext.: Used to indicate magazines and newspaper issue numbers 5-Digit Ext.: Used to mark suggested retail price of books

code:string = code to represent. len:int = barcode type: 2 = 2-Digit, 5 = 5-Digit

return = array barcode representation.

proc barcode_msi(code: string; checksum: bool = false): BarArray {...}{.
    raises: [ValueError, OSError, KeyError], tags: [].}

MSI Variation of Plessey code, with similar applications Contains digits (0 to 9) and encodes the data only in the width of bars.

code:string = code to represent. checksum:bool = if true add a checksum to the code (modulo 11)

return = array barcode representation.

proc barcode_postnet(code: string; planet: bool = false): BarArray {...}{.
    raises: [ValueError], tags: [].}

POSTNET and PLANET barcodes. Used by U.S. Postal Service for automated mail sorting Contains digits (0 to 9) and encodes the data only in the width of bars.

code:string = zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD. planet:bool = if true print the PLANET barcode, otherwise print POSTNET

return = array barcode representation.

proc barcode_rms4cc(code: string; kix: bool = false): BarArray {...}{.
    raises: [ValueError, KeyError], tags: [].}

RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant index - Customer index) RM4SCC is the name of the barcode symbology used by the Royal Mail for its Cleanmail service.

code:string = zip code to represent. Must be a string containing a zip code of the form DDDDD or DDDDD-DDDD.

kix:bool = if true prints the KIX variation (doesn't use the start and end symbols, and the checksum)
  • in this case the house number must be sufficed with an X and placed at the end of the code.

return = array barcode representation.

proc barcode_codabar(code: string): BarArray {...}{.
    raises: [OSError, KeyError, ValueError], tags: [].}

CODABAR barcodes. Older code often used in library systems, sometimes in blood banks

code:string = code to represent

return = array barcode representation.

proc barcode_code11(code: string): BarArray {...}{.
    raises: [ValueError, OSError, KeyError], tags: [].}

CODE11 barcodes. Older code often used in library systems, sometimes in blood banks

code:string = code to represent

return = array barcode representation.

proc barcode_pharmacode(code: string): BarArray {...}{.raises: [ValueError], tags: [].}

Pharmacode Contains digits (0 to 9)

code:string = code to represent

return = array barcode representation.

proc barcode_pharmacode2t(code: string): BarArray {...}{.raises: [ValueError], tags: [].}

Pharmacode two-track Contains digits (0 to 9)

code:string = code to represent

return = array barcode representation.

proc barcode_imb(code: string): BarArray {...}{.raises: [ValueError, OSError, Exception,
    KeyError], tags: [RootEffect].}
IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 Intelligent Mail barcode is a 65-bar code for use on mail in the United States.
The fields are described as follows:
  • The Barcode Identifier shall be assigned by USPS to encode the presort identification that is currently printed in human readable form on the optional endorsement line (OEL) as well as for future USPS use. This shall be two digits, with the second digit in the range of 0–4. The allowable encoding ranges shall be 00–04, 10–14, 20–24, 30–34, 40–44, 50–54, 60–64, 70–74, 80–84, and 90–94.
  • The Service Type Identifier shall be assigned by USPS for any combination of services requested on the mailpiece. The allowable encoding range shall be 000–999. Each 3-digit value shall correspond to a particular mail class with a particular combination of service(s). Each service program, such as OneCode Confirm and OneCode ACS, shall provide the list of Service Type Identifier values.
  • The Mailer or Customer Identifier shall be assigned by USPS as a unique, 6 or 9 digit number that identifies a business entity. The allowable encoding range for the 6 digit Mailer ID shall be 000000-899999, while the allowable encoding range for the 9 digit Mailer ID shall be 900000000-999999999.
  • The Serial or Sequence Number shall be assigned by the mailer for uniquely identifying and tracking mailpieces. The allowable encoding range shall be 000000000–999999999 when used with a 6 digit Mailer ID and 000000-999999 when used with a 9 digit Mailer ID. e. The Delivery Point ZIP Code shall be assigned by the mailer for routing the mailpiece. This shall replace POSTNET for routing the mailpiece to its final delivery point. The length may be 0, 5, 9, or 11 digits. The allowable encoding ranges shall be no ZIP Code, 00000–99999, 000000000–999999999, and 00000000000–99999999999.

code:string = code to represent. , separate the ZIP (routing code) from the rest using a minus char '-' (BarcodeID_ServiceTypeID_MailerID_SerialNumber-RoutingCode)

return = array barcode representation.

proc checksum_s25(code: string): string {...}{.raises: [ValueError], tags: [].}
proc checksum_code93(code: string): string {...}{.raises: [], tags: [].}

Calculate CODE 93 checksum (modulo 47).

code: string = code to represent

return: string = checksum code

proc checksum_code39(code: string): string {...}{.raises: [], tags: [].}
proc get128ABsequence(code: string): seq[seq[string]] {...}{.raises: [RegexError], tags: [].}