bytescoutbarcode128.js documentation:
What is bytescoutbarcode128.js? This client-side javascript script made with pure javascript code allows you to generate Code 128 barcodes.
No server-side code is required
SAMPLE CODE (see /Examples/ folder for more samples):
Main class: bytescoutbarcode128
bytescoutbarcode128 class methods and properties:
Document:
-
valueSet(value) - sets value to encode as Code 128 barcode
Available parameters are:
- value - value to set for the barcode
-
setMargins(left, top, right, bottom) - sets margins for the barcode
Available parameters are:
- left - left margin
- top - top margin
- right - right margin
- bottom - bottom margin
-
setMinBarWidth(width) - sets min bar width (need to calculate min size of the barcode)
Available parameters are:
- width - min width of one single bar
-
setMinBarWidth(width) - sets min bar width (need to calculate min size of the barcode)
Available parameters are:
- width - min width of one single bar
-
setMinBarWidth(width) - sets min bar width (need to calculate min size of the barcode)
Available parameters are:
- width - min width of one single bar
-
setMinBarWidth(width) - sets min bar width (need to calculate min size of the barcode)
Available parameters are:
- width - min width of one single bar
-
setBarWidth(width) - sets one single bar width (need to calculate final size of the barcode)
Available parameters are:
- width - width of one single bar
-
valueFits() - returns True if barcode required for currently set value fits into currently set width, height, and bar width settings
-
getMinWidth() - returns min width required for the barcode with currently set value.
-
getBarWidth() - returns one single bar width. To set bar width use setBarWidth() method
-
getBarHeight() - returns one single bar height.
-
setBarWidth(width) - sets one single bar width (need to calculate final size of the barcode)
Available parameters are:
- width - width of one single bar
-
setCodeSet(codeSet) - set code set (encoding) to use.
Available parameters are:
- codeSet - sets the codeset (encoding) to use. Available values:
-
bytescoutbarcode128.Auto - automatically selects the encoding needed and mixes use of codesets when needed. Allows to encode almost all characters.
-
bytescoutbarcode128.A - uses A encoding where it allows to encode only ASCII characters 00 to 95 (0-9, A-Z and control codes), special characters, and FNC 1-4).
-
bytescoutbarcode128.B - uses B encoding where it allows to encode only ASCII characters 32 to 127 (0-9, A-Z, a-z), special characters, and FNC 1-4.
-
bytescoutbarcode128.C - uses C encoding where it allows to encode only 00-99 (encodes each two digits with one code) and FNC1.
-
resetCode() - resets settings for width, height, value, codeset options to their default values
-
setCaption(caption, fontName, fontSize) - sets caption text and font for barcode
Available parameters are:
- caption - caption text
- fontName - name of the font to use
- fontSize - size of the font to use
-
setCaptionVisibility(visible) - sets visibility of caption
Available parameters are:
- visible - set to True to show caption, False to hide caption
-
setCaptionColor(R,G,B) - sets caption color
Available parameters are:
- R - R parameter to set color (from 0 to 255)
- G - G parameter to set color (from 0 to 255)
- B - B parameter to set color (from 0 to 255)
-
setBackgroundColor(R,G,B) - sets background color for barcode
Available parameters are:
- R - R parameter to set color (from 0 to 255)
- G - G parameter to set color (from 0 to 255)
- B - B parameter to set color (from 0 to 255)
-
setBarColor(R,G,B) - sets color for bars inside barcode
Available parameters are:
- R - R parameter to set color (from 0 to 255)
- G - G parameter to set color (from 0 to 255)
- B - B parameter to set color (from 0 to 255)
-
exportToCanvas(canvas, angle) - generates and exports barcode into given canvas
Available parameters are:
- canvas - canvas object to draw barcode on
- angle - angle to rotate barcode (from 0 to 360)
-
exportToBase64(width, height, angle) - generates and exports barcode into base64 encoded image (so you can show it as datauri)
Available parameters are:
- width - width of barcode image
- height - height of barcode image
- angle - angle to rotate barcode (from 0 to 360)
-
exportToImageDataBase64(width, height, angle) - generates and exports barcode into base64 encoded image (so you can show it as datauri) without data:image/png;base64 prefix so image data can be save to a file
Available parameters are:
- width - width of barcode image
- height - height of barcode image
- angle - angle to rotate barcode (from 0 to 360)