Custom Design for Barcode control.

5 Dec 201816 minutes to read

$(element).ejBarcode()

Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
     
    <script>
    //Create the barcode by setting the symbologyType and providing input URL to the text property. QR code is rendered by default.
          $("#barcode").ejBarcode({
             text: "http://www.syncfusion.com"
          });         
    </script>

    Requires

    • module:jQuery
    • module:ej.common.all

    Members

    barcodeToTextGapHeight number

    Specifies the distance between the barcode and text below it.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • 10 pixels

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set barcodeToTextGapHeight during initialization  
     $("#barcode").ejBarcode({
         text: "SYNCFUSION",
         symbologyType: "code39",
         barcodeToTextGapHeight: 50
     });
    </script>

    barHeight number

    Specifies the height of bars in the Barcode. By modifying the barHeight, the entire barcode height can be customized. Please refer to xDimension for two dimensional barcode height customization.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • 150 pixels

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set barHeight during initialization  
     $("#barcode").ejBarcode({
         text: "SYNCFUSION",
         symbologyType: "code39",
         barHeight: 50
     });
    </script>

    darkBarColor object

    Specifies the dark bar color of the Barcode. One dimensional barcode contains a series of dark and light bars which are usually colored as black and white respectively.

    NOTE

    1. For the barcode should be properly detected by all scanners, choose the best possible contrast color.
      2. This property is applicable only for one dimensional barcode.

    Default Value:

    • black

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set darkBarColor during initialization  
     $("#barcode").ejBarcode({
         text: "SYNCFUSION",
         symbologyType: "code39",
         darkBarColor: "blue"
     });
    </script>

    displayText boolean

    Specifies whether the text below the barcode is visible or hidden.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • true

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to hide displayText during initialization  
     $("#barcode").ejBarcode({
         text: "SYNCFUSION",
         symbologyType: "code39",
         displayText: false
     });
    </script>

    enabled boolean

    Specifies whether the control is enabled.

    Default Value:

    • true

    encodeStartStopSymbol number

    Specifies the start and stop encode symbol in the Barcode. In one dimensional barcodes, an additional character is added as start and stop delimiters. These symbols are optional and the unique of the symbol allows the reader to determine the direction of the barcode being scanned.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • true

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to remove encodeStartStopSymbol during initialization  
     $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        encodeStartStopSymbol: false
     });
    </script>

    lightBarColor object

    Specifies the light bar color of the Barcode. One dimensional barcode contains a series of dark and light bars which are usually colored as black and white respectively.

    NOTE

    1. For the barcode should be properly detected by all scanners, choose the best possible contrast color.
      2. This property is applicable only for one dimensional barcode.

    Default Value:

    • white

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set lightBarColor during initialization  
     $("#barcode").ejBarcode({
         text: "SYNCFUSION",
         symbologyType: "code39",
         lightBarColor: "blue"
     });
    </script>

    narrowBarWidth number

    Specifies the width of the narrow bars in the barcode. The dark bars in the one dimensional barcode contains random narrow and wide bars based on the provided input which can be specified during initialization.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • 1 pixel

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set narrowBarWidth during initialization  
     $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        narrowBarWidth: 5
     });
    </script>

    quietZone object

    Specifies the width of the quiet zone. In barcode, a quiet zone is the blank margin on either side of a barcode which informs the reader where a barcode’s symbology starts and stops. The purpose of a quiet zone is to prevent the reader from picking up unrelated information.

    quietZone.all number

    Specifies the quiet zone around the Barcode.

    Default Value:

    • 1 pixel

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set quiet zone during initialization  
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        quietZone: {
            all: 10
        }
    });
    </script>

    quietZone.bottom number

    Specifies the bottom quiet zone of the Barcode.

    Default Value:

    • 1 pixel

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set quiet zone during initialization  
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        quietZone: {
            bottom: 10
        }
    });
    </script>

    quietZone.left number

    Specifies the left quiet zone of the Barcode.

    Default Value:

    • 1 pixel

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set quiet zone during initialization  
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        quietZone: {
            left: 10
        }
    });
    </script>

    quietZone.right number

    Specifies the right quiet zone of the Barcode.

    Default Value:

    • 1 pixel

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set quiet zone during initialization  
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        quietZone: {
            right: 10
        }
    });
    </script>

    quietZone.top number

    Specifies the top quiet zone of the Barcode.

    Default Value:

    • 1 pixel

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set quiet zone during initialization  
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        quietZone: {
            top: 10
        }
    });
    </script>

    symbologyType enum

    Specifies the type of the Barcode. See SymbologyType

    Name Description
    QRBarcode Represents the QR code
    DataMatrix Represents the Data Matrix barcode
    Code39 Represents the Code 39 barcode
    Code39Extended Represents the Code 39 Extended barcode
    Code11 Represents the Code 11 barcode
    Codabar Represents the Codabar barcode
    Code32 Represents the Code 32 barcode
    Code93 Represents the Code 93 barcode
    Code93Extended Represents the Code 93 Extended barcode
    Code128A Represents the Code 128 A barcode
    Code128B Represents the Code 128 B barcode
    Code128C Represents the Code 128 C barcode

    Default Value:

    • ej.Barcode.SymbologyType.QRBarcode

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set the SymbologyType during initialization  
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39"
        }
    });
    </script>

    text string

    Specifies the text to be encoded in the barcode.

    Default Value:

    • empty

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
     
    <script>
    // All the below script to set the text to be encoded while initialization.
          $("#barcode").ejBarcode({
             text: "http://www.syncfusion.com"
          });         
    </script>

    textColor object

    Specifies the color of the text/data at the bottom of the barcode.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • black

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
     
    <script>
    // All the below script to set the textColor while initialization.
    $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        textColor: "blue"
    });       
    </script>

    wideBarWidth number

    Specifies the width of the wide bars in the barcode. One dimensional barcode usually contains random narrow and wide bars based on the provided which can be customized during initialization.

    NOTE

    This property is applicable only for one dimensional barcode.

    Default Value:

    • 3 pixels

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set wideBarWidth during initialization  
     $("#barcode").ejBarcode({
        text: "SYNCFUSION",
        symbologyType: "code39",
        wideBarWidth: 5
     });
    </script>

    xDimension number

    Specifies the width of the narrowest element(bar or space) in a barcode. The greater the x dimension, the more easily a barcode reader will scan.

    NOTE

    This property is applicable only for two dimensional barcode.

    Default Value:

    • 4 pixels

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode">Barcode</div> 
    
    <script>
    // Add the script below to set xDimension during initialization  
    $("#barcode").ejBarcode({
        text: "http://www.syncfusion.com",
        xDimension: 10
    });
    </script>

    Methods

    disable()

    To disable the barcode

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode"> </div> 
     
    <script>
    // Create Barcode
    var btnObj = $("#barcode").data("ejBarcode");
    btnObj.disable(); // disable the barcode
    </script>
  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode"> </div> 
     
    <script>
    // disable the barcode
    $("#barcode").ejBarcode("disable");    
    </script>

    enable()

    To enable the barcode

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode"> </div> 
     
    <script>
    // Create Barcode
    var btnObj = $("#barcode").data("ejBarcode");
    btnObj.enable(); // enable the barcode
    </script>
  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode"> </div> 
     
    <script>
    // enable the barcode
    $("#barcode").ejBarcode("enable");     
    </script>

    Events

    load

    Fires after Barcode control is loaded.

    Name Type Description
  • HTML
  • argument
    Object Event parameters from barcode
    Name Type Description
  • HTML
  • cancel
    boolean if the event should be canceled; otherwise, false.
  • HTML
  • model
    object returns the barcode model
  • HTML
  • type
    string returns the name of the event
  • HTML
  • status
    boolean return the barcode state

    Example

  • HTML
  • //Add div container for barcode rendering.
    <div id="barcode"> </div> 
     
    //create event for barcode
    $("#barcode").ejBarcode({
       load: function (args) {}
    });