BarcodeGenerator
23 Sep 20255 minutes to read
Represents the Barcode control
<div id='barcode'/>let barcode: Barcode = new Barcode({
width:'1000px', height:'500px' });
barcode.appendTo('#barcode');Properties
backgroundColor string
Defines the background color of the barcode.
Defaults to ‘white’
displayText DisplayTextModel
Defines the text properties for the barcode.
Defaults to ’’
enableCheckSum boolean
Defines the checksum for the barcode.
Defaults to ‘true’
enablePersistence boolean
Enable or disable persisting component’s state between page reloads.
Defaults to false
enableRtl boolean
Enable or disable rendering component in right to left direction.
Defaults to false
foreColor string
Defines the forecolor of the barcode.
Defaults to ‘black’
height string|number
Defines the height of the barcode model.
<div id='barcode'/>let barcode: Barcode = new Barcode({
height:'1000px', height:'500px' });
barcode.appendTo('#barcode');Defaults to ‘100’
locale string
Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.
Defaults to ’’
margin MarginModel
Defines the margin properties for the barcode.
Defaults to ’’
mode RenderingMode
Defines the barcode rendering mode.
- SVG - Renders the bar-code objects as SVG elements
- Canvas - Renders the bar-code in a canvas
Defaults to ‘SVG’
type BarcodeType
Defines the type of barcode to be rendered.
Defaults to ‘Code128’
value string
Defines the value of the barcode to be rendered.
Defaults to undefined
width string|number
Defines the width of the barcode model.
<div id='barcode'/>let barcode: Barcode = new Barcode({
width:'1000px', height:'500px' });
barcode.appendTo('#barcode');Defaults to ‘100%’
Methods
addEventListener
Adds the handler to the given event listener.
| Parameter | Type | Description |
|---|---|---|
| eventName | string |
A String that specifies the name of the event |
| handler | Function |
Specifies the call to run when the event occurs. |
Returns void
appendTo
Appends the control within the given HTML element
| Parameter | Type | Description |
|---|---|---|
| selector (optional) |
string | HTMLElement
|
Target element where control needs to be appended |
Returns void
attachUnloadEvent
Adding unload event to persist data when enable persistence true
Returns void
dataBind
When invoked, applies the pending property changes immediately to the component.
Returns void
destroy
It is used to destroy the Barcode component.
Returns void
detachUnloadEvent
Removing unload event to persist data when enable persistence true
Returns void
exportAsBase64Image
Export the barcode as an image in the specified image type and returns it as base64 string.
| Parameter | Type | Description |
|---|---|---|
| exportType | BarcodeExportType |
Defines the format of the barcode to be exported |
Returns Promise
exportImage
Export the barcode as an image in the specified image type and downloads it in the browser.
| Parameter | Type | Description |
|---|---|---|
| filename | string |
Specifies the filename of the barcode image to be download. |
| exportType | BarcodeExportType |
Defines the format of the barcode to be exported |
Returns void
getLocalData
Returns the persistence data for component
Returns any
getModuleName
Returns the module name of the barcode
Returns string
getPersistData
Get the properties to be maintained in the persisted state.
Returns string
getRootElement
Returns the route element of the component
Returns HTMLElement
handleUnload
Handling unload event to persist data when enable persistence true
Returns void
refresh
Applies all the pending property changes and render the component again.
Returns void
removeEventListener
Removes the handler from the given event listener.
| Parameter | Type | Description |
|---|---|---|
| eventName | string |
A String that specifies the name of the event to remove |
| handler | Function |
Specifies the function to remove |
Returns void
render
Renders the barcode control with nodes and connectors
Returns void
Inject
Dynamically injects the required modules to the component.
| Parameter | Type | Description |
|---|---|---|
| moduleList | Function[] |
? |
Returns void
Events
invalid EmitType<Object>
Triggers if you enter any invalid character.