Using Barcodes for More Effective Document Management

Barcodes have been in commercial use since the mid-1970s. While they are most known for their application in retail or warehousing, today barcodes are extensively used in document management. Typical usage of barcodes in document management includes:

In this article, we explore these applications and how Dynamic Web TWAIN SDK can enhance your business workflow.

Split

In the case of batch documents, barcodes can act as intelligent separators, or used to appropriately group documents. For instance, a barcode affixed to each document in a batch allows for automatic grouping or separation of files after scanning. This can be accomplished with a single batch scan.

split

Data capture systems can automatically read barcodes on a file. Whenever a barcode is detected, a new file is created, and the barcode value is assigned as the file name.

Below is a code snippet that reads all documents and uses those with barcodes to separate them into different documents. You can also try to split your document by barcode in this online demo.

// `aryIndices` consists of multiple arrays each of which represents a document
var aryIndices = [],
    bBarcodeFound = false,
    ProcssedImagesCount = 0;
j;
function ReadBarcode(index) {
    DWObject.Addon.BarcodeReader.decode(index)
        .then(function(results) {
                ProcssedImagesCount++;
                if (results.length === 0) {
                    console.log('no barcode found on image index ' + index);
                    if (bBarcodeFound === true) {
                        // If a barcode was found earlier, this image belongs to the current document
                        bBarcodeFound = false;
                        if (aryIndices.length === 0)
                            aryIndices.push([index]);
                        else
                            aryIndices[aryIndices.length - 1].push(index);
                    } else {
                        // If no barcode has been found yet, this image belongs to the first document
                        if (aryIndices.length === 0)
                            aryIndices.push([index]);
                        else
                            aryIndices[aryIndices.length - 1].push(index);
                    }
                } else {
                    console.log('barcode found on image index ' + index);
                    if (ProcssedImagesCount === DWObject.HowManyImagesInBuffer) {
                        //If it is the last image, no need to set this flag to true nor create a new document
                        bBarcodeFound = false;
                    } else {
                        bBarcodeFound = true;
                        // Found a barcode, create a new one
                        if (aryIndices.length === 0)
                            aryIndices.push([]);
                        else if (aryIndices[aryIndices.length - 1].length != 0)
                            aryIndices.push([]);
                    }
                }
                if (ProcssedImagesCount === DWObject.HowManyImagesInBuffer) {
                    // Print out the indice arrays, each array represents a document
                    console.log(aryIndices);
                    aryIndices = [];
                } else
                    /*
                     * Read the next image
                     */
                    ReadBarcode(index + 1);
            },
            function(errorMsg) {
                console.log(errorMsg);
            }
        );
}
ReadBarcode(0);

Classify / Route

Categorize documents using the barcode separator

classify

Barcodes can also be employed in file routing. Barcodes are detected and used to determine the target path within a computer’s file system. If the path does not exist, a new folder can be created. This is particularly useful to automatically group thousands of files based on the document type, such as invoices for different vendors.

Categorize scanned documents using barcode identification

scan-and-save-using-barcode

Auto-classification can be used along with document scanning. Barcodes help identify the type of documents being scanned. Data capture systems can analyze the content of the barcodes to decide the next appropriate steps. Files of one type can either be moved to a specific folder or saved as a multi-page TIFF/PDF file.

The following code reads all barcodes from all documents and puts documents which have the same barcode into one document. Documents without any barcodes are put into another separate document. You can try to categorize your document by barcode in this online demo.

// `aryIndices` consists of multiple arrays each of which represents a document
var aryIndices = {
        'noBarcode': []
    },
    ProcssedImagesCount = 0;

function ReadBarcode(index) {
    var j,
        bBarcodeFound = false;
    DWObject.Addon.BarcodeReader.decode(index).then(function(results) {
            ProcssedImagesCount++;
            if (results.length === 0) {
                console.log('no barcode found on image index ' + index);
                aryIndices.noBarcode.push(index);
            } else {
                console.log('barcode found on image index ' + index);
                var barcodeOnThisImage = [],
                    allKeys = [];
                for (j = 0; j < results.length; j++) {
                    var result = results[j];
                    var barcodeText = result.barcodeText;
                    // Record all barcodes found on this image
                    if (barcodeOnThisImage.indexOf(barcodeText) === -1)
                        barcodeOnThisImage.push(barcodeText);
                }

                Dynamsoft.Lib.each(aryIndices, function(value, key) {
                    allKeys.push(key);
                });

                for (j = 0; j < allKeys.length; j++) {
                    var oKey = allKeys[j];
                    if (barcodeOnThisImage.indexOf(oKey) != -1) {
                        barcodeOnThisImage.splice(barcodeOnThisImage.indexOf(oKey), 1);
                        var _value = aryIndices[oKey];
                        if (_value.indexOf(index) === -1) {
                            _value.push(index);
                            aryIndices[oKey] = _value;
                        }
                    }
                }
                for (j = 0; j < barcodeOnThisImage.length; j++) {
                    aryIndices[barcodeOnThisImage[j]] = [index];
                }
            }
            if (ProcssedImagesCount === DWObject.HowManyImagesInBuffer) {
                ProcssedImagesCount = 0;
                var aryTemp = [];
                Dynamsoft.Lib.each(aryIndices, function(value, key) {
                    aryTemp.push(value);
                });
                aryIndices = aryTemp;
                console.log(aryIndices);
                aryIndices = {
                    'noBarcode': []
                };
            } else
                /*
                 * Read the next image
                 */
                ReadBarcode(index + 1);

        },
        function(errorMsg) {
            console.log(errorMsg);
        }
    );
}
ReadBarcode(0);

Automatic File Renaming

Rename documents using the value of barcode

You can automate renaming of files to associate them with other items, such as another file to match. In many cases, the first page of a file has a barcode encoded with meaningful info. For example, a patient’s chart might have his or her ID on it. This removes an otherwise tedious user task, especially when you deal with a lot of documents.

rename

Case Study

This was the case for the German Red Cross’s accounting department. They deal with a lot of invoices and wanted to automate much of the workflow. With barcodes, they were able to achieve that. When an invoice is received they put a label with an identifier barcode on the document. It is then scanned with Dynamsoft Barcode Reader. Upon scanning, the invoice is automatically renamed with the barcode value for simpler tracking. The invoice can then go to the treasurer and online bank for payment processing. The renamed PDF helps the treasurer relate the invoice to information returned from the bank, to properly record transactions. After payment processing, the entire transaction flow is recorded to the database for record keeping. The treasurer can then see the detailed transaction information from the online accounting system.

Index

Barcodes are often used to contain metadata or indexing information for document management systems. After the barcode is detected, the value can be compared against some data, possibly a key identifier, from the database, and then the next step can be decided.

Sometimes the newly scanned documents are associated with the record in the database. For example, a small software development consultancy based on the US East coast has a healthcare practice client using an application to scan and manage patient records. The medical users previously had to do the following steps to manage patient records:

  1. Place one document or patient record at a time in the scanner
  2. Select the correct patient
  3. Select the correct document type
  4. Type a description
  5. Finally, press scan button and then save the files

They then introduced QR codes to their document workflow and it saves time on the previous manual data entry. Now they:

  1. Print documents with an encoded QR code or attach a QR-coded label that includes the data of a record number and document type.
  2. With the QR code put on the first page of a document, during scanning, the barcode reader automatically determines the correct patient ID and document type and any scanned documents then automatically go to corresponding locations.

Dynamsoft Barcode and Imaging SDKs

In conclusion, Dynamsoft provides complete solutions for document capture, barcode reading, and more. These SDKs allow developers to create comprehensive document management applications that work across various software and hardware platforms.

If you need assistance in integrating scanning/capture, barcodes, or other document management features into your business’ workflow or applications, please contact us.

Sample code and demo: