Barcode Xpress for Node.js v13.9 - Updated
Create Your First Project
Getting Started > Create Your First Project

Introduction

This step-by-step tutorial will guide you through how to build a complete application that analyzes a Code 39 barcode from an image and output the value, type, location, and confidence to the terminal. For this tutorial, you can use any text editor (vim, gedit, emacs, etc.).

You may want to try our sample application first before creating your first project.

Steps

  1. Create a new file titled BXDemo.js

  2. Import the Barcode module:

    const bx = require("barcode-js");
    
    
  3. Create the parameters to use for recognition: the input image and the barcode type to recognize. Change the file name in this example to an image on your local system:

    const filePath = "filePath/fileName.bmp";
    const params = {
        type: bx.BarcodeType.ALL
    };
    
    

    Specifying only the barcode type or types that you are interested in will speed up the analysis. For example, you can use "code39", ["code39", "code128"], or "all". If you omit the barcode type completely, "all" is assumed.

  4. Perform analyze on your barcode image:

    const analyzeBarcodes = async (filePath, params) => {
        try {
            const results = await bx.analyze(filePath, params);
            console.log(JSON.stringify(results, ["type", "value", "confidence"], 2));
        }
        catch(err) {
            console.error(`There was an error processing this image\n${err}`);
        }
    }
    
    analyzeBarcodes(filePath, params);
    
    
  5. That’s it! Now go to the console and run your application to see the result output data:

    $ node BXDemo
    
    
Is this page helpful?
Yes No
Thanks for your feedback.