Barcode - BarcodeGenerator
18 Nov 20266 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’
bearerBar BearerBarType
Defines the bearer bars for the ITF14 type. Other types ignore it.
Defaults to ‘Frame’
bearerBarWidth number
Defines the bearer bar thickness, as a multiple of the narrow bar width,
from 1 to 10, for the ITF14 type. Other types ignore it.
Defaults to 5
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
enableWebMcp boolean
Specifies whether the WebMCP integration is enabled in the component.
When set to true, the component provides a set of tools with schemas and execute functions
that allow AI models to perform actions within the component context.
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’
segmentsPerRow number
Defines the number of segments in each row of a GS1DataBarExpandedStacked barcode:
an even number from 2 to 20. Other types ignore it.
Defaults to 4
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
webMcpSettings WebMcpBarcodeSettingsModel
Configures WebMCP tool registration and exposure settings.
When set, tools are automatically registered with the provided configuration.
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
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
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
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
getWebMcpTools
Returns the WebMCP tool schemas for the given tool names.
When toolNames is omitted, schemas for all available tools are returned.
| Parameter | Type | Description |
|---|---|---|
| toolNames (optional) | string[] |
Optional: filter tool names. Omit to get all tools. |
Returns WebMcpTool[]
refresh
Applies all the pending property changes and render the component again.
Returns void
registerWebMcpTools
Registers WebMCP tools on document.modelContext for this component instance.
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
beforeWebMcpToolExecute EmitType<WebMcpToolExecuteEventArgs>
Triggers before a WebMCP tool execution begins.
Set args.cancel to true to prevent the tool from running, or args.showConfirmationDialog
to ask the user for confirmation first.
invalid EmitType<Object>
Triggers if you enter any invalid character.