Fliplet.Barcode
Install
Add the fliplet-barcode
dependency to your screen or app resources.
Fliplet.Barcode.scan()
(Returns Promise
)
Scan a QR code or barcode.
Note: Barcode scanning is only supported in native apps.
Usage
Fliplet.Barcode.scan(options).then(function (result) {
// result.text
// result.format
// result.cancelled
}).catch(function (error) {
// scan failed
});
- options (Object) A map of optional configurations for the scanner. See PhoneGap Plugin BarcodeScanner documentation for a full list of supported options. The default options used by Fliplet is listed below.
options = {
preferFrontCamera: false, // iOS and Android
showFlipCameraButton: true, // iOS and Android
showTorchButton: true, // iOS and Android
torchOn: false, // Android, launch with the torch switched on (if available)
saveHistory: true, // Android, save scan history (default false)
prompt: 'Place a barcode inside the scan area', // Android
};
Fliplet.Barcode.show()
(Returns Promise
)
Encode text into QR code or barcode and show it on the screen.
Note: A QR code is generated by default unless an alternative format is provided (see below).
Usage
Fliplet.Barcode.show(text).then(function (data) {
// data (String) Encoded Base64 string
}).catch(function (error) {
// encoding failed
});
- text (String) String to be encoded into a QR code and displayed
Fliplet.Barcode.show(text, options).then(function (data) {
// data (String) Encoded Base64 string
}).catch(function (error) {
// encoding failed
});
- text (String) String to be encoded into a QR code or barcode and displayed
- options (Object) A map of options for the encoding
- format (String) Format to encode the provided text with. See below for a list of supported formats:
qr
(Default)barcode
- This will encode the provided text incode128
format. See below for a specific list of supported formats as supported by JsBarcode.code39
,code128
,code128A
,code128B
,code128C
,ean13
,ean8
,ean5
,ean2
,upc
,upce
,itf14
,itf
,msi
,msi10
,msi11
,msi1010
,msi1110
,pharmacode
,codabar
,genericbarcode
- color (String) Foreground color for the barcode. This can be a color keyword (e.g.
green
) or hexcode (e.g.#00ff00
). Default#000000
- background (String) Background color for the barcode. This can be a color keyword (e.g.
green
) or hexcode (e.g.#00ff00
). Default#ffffff
- title (String) Optional title to show to the user
- message (String) Optional message to show to the user
- height (Number) Barcode only - Height of barcode image. Default
150
- lineWidth (Number) Barcode only - Width of a single bar. The higher this number, the wider the result image. Default
2
- format (String) Format to encode the provided text with. See below for a list of supported formats:
Note If a barcode is generated instead of a QR code, adjust height
and lineWidth
according to the text length. Fliplet recommends using QR codes unless a barcode is required because QR codes are always generated in a 1:1 aspect ratio.
Fliplet.Barcode.encode()
(Returns Promise
)
Encode text into QR code or barcode and return it as a Base64 image.
Note: A QR code is generated by default unless an alternative format is provided (see below).
Usage
Fliplet.Barcode.encode(text).then(function (data) {
// data (String) Encoded Base64 string
}).catch(function (error) {
// encoding failed
});
- text (String) String to be encoded into a QR code
Fliplet.Barcode.encode(text, options).then(function (data) {
// data (String) Encoded Base64 string
}).catch(function (error) {
// encoding failed
});
- text (String) String to be encoded into a QR code or barcode
- options (Object) A map of options for the encoding
- format (String) Format to encode the provided text with. See below for a list of supported formats:
qr
(Default)barcode
- This will encode the provided text incode128
format. See below for a specific list of supported formats as supported by JsBarcode.code39
,code128
,code128A
,code128B
,code128C
,ean13
,ean8
,ean5
,ean2
,upc
,upce
,itf14
,itf
,msi
,msi10
,msi11
,msi1010
,msi1110
,pharmacode
,codabar
,genericbarcode
- color (String) Foreground color for the barcode. This can be a color keyword (e.g.
green
) or hexcode (e.g.#00ff00
). Default#000000
- background (String) Background color for the barcode. This can be a color keyword (e.g.
green
) or hexcode (e.g.#00ff00
). Default#ffffff
- width (Number) QR code only - Width of QR code image. Default
600
.- Note: For barcodes, the result width depends on the length of text encoded and the width of a single bar as configured via
lineWidth
(see below).
- Note: For barcodes, the result width depends on the length of text encoded and the width of a single bar as configured via
- height (Number) Height of QR code or barcode image. Default
600
for QR code,150
for barcode - lineWidth (Number) Barcode only - Width of a single bar. The higher this number, the wider the result image. Default
2
- format (String) Format to encode the provided text with. See below for a list of supported formats:
Note If a barcode is generated instead of a QR code, adjust height
and lineWidth
according to the text length. Fliplet recommends using QR codes unless a barcode is required because QR codes are always generated in a 1:1 aspect ratio.