Using Barcode as Separator in Batch Document Scanning

1D Barcode

For document management solutions, it is a common requirement that a user puts a stack of documents for automatic document feeder (ADF) scanning. The documents may be for different purposes and he wants to automatically save them into different files after the scanning finishes. This way, it will greatly save the time.

So how can we achieve that? How to enable users to do that on your website or with your web application? Dynamsoft’s Dynamic Web TWAIN and Dynamsoft Barcode Reader JavaScript Edition working together can satisfy your needs well.

  • Dynamic Web TWAIN is an image acquisition library which enables you to acquire images from TWAIN compatible scanners, editing the images and upload them to a web server, database or other repositories. It has ActiveX, and HTML5 editions which support all the mainstream browsers on Windows, macOS, and Linux, including IE (x86/x64), Chrome, Firefox, Safari and Opera.
    Dynamic Web TWAIN is a client-side image capture API and you can use JavaScript to call its methods/properties.
  • Dynamsoft Barcode Reader JavaScript Edition supports both 1D & 2D barcode detection and recognition.

Online Demo

You can test scanning documents or loading an existing image into the SDK and recognize the barcode online. Each barcode works as a separator. Pages between two neighbor barcodes are saved as one file.
Try out online demo

A Simple Sample

Below is a simple sample (HTML/JavaScript + C#) for demonstrating how to use Dynamic Web TWAIN to do ADF batch scanning and save the documents into different PDF files to web server automatically based on barcode separator.

Besides C#, you can also use your preferred server-side language, like PHP, VB.NET, JSP,  for the image upload part.

On client side: 

    // scan documents in a batch
    function AcquireImage() {
	if (DWObject) {
		DWObject.SelectSourceByIndex(document.getElementById("source").selectedIndex);
		DWObject.OpenSource();
		DWObject.IfDisableSourceAfterAcquire = true;	// Scanner source will be disabled/closed automatically after the scan.
		DWObject.IfFeederEnabled = true;
		DWObject.IfShowUI = false;
		DWObject.AcquireImage();
	}
}

              

//Get barcode result.
function ReadBarcode(i) {
	var index=i;
	if(index == DWObject.HowManyImagesInBuffer) 
	    return;
	if(dbrObject){
		dbrObject.barcodeFormats = BarcodeInfo[document.getElementById("barcodeformat").selectedIndex].val;
		var barcodeImage = DWObject.GetImageURL(index, -1, -1);

		dbrObject.readURLAsync(barcodeImage,
						   index,
						   OnBarcodeReadSuccess,
						   OnBarcodeReadFailure);

		function OnBarcodeReadSuccess(sImageIndex, result) {
			ProcssedImagesCount++;
			var count = result.getCount();
			if (count == 0) {
				UpdateInfo("No barcode found for the selected formats on image index " + sImageIndex, false);
			}
			else {
				UpdateInfo("Barcode found on image index " + sImageIndex, true);
				for (var j = 0; j < count; j++) {
					var barcodeText = result.get(j).text;
					UpdateInfo("Barcode index " + j + ": " + barcodeText, false);
					var imageArray = {
						indexes: sImageIndex,
						text: barcodeText
					}
					imageArrays.push(imageArray);
				}
			}
			if (ProcssedImagesCount == DWObject.HowManyImagesInBuffer) {
				ProcssedImagesCount = 0;
				UploadImagesSeparatedByBarcode();
			}
			/*
			* Read the next image
			*/
			ReadBarcode(sImageIndex + 1);
		}

		function OnBarcodeReadFailure(sImageIndex, errorCode, errorString) {
			alert(errorString);
		}
	}
}

function SaveFile() {
	DWObject.IfShowProgressBar = false;
	imageArrays = [];
	ReadBarcode(0);
}     

Server Side – SaveToFile.aspx:

<%@ Page Language="c#" AutoEventWireup="false" Debug="True"%>

<% HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile uploadfile = files["RemoteFile"]; uploadfile.SaveAs(System.Web.HttpContext.Current.Request.MapPath(".") + "/" + uploadfile.FileName); %>

Get Samples
You can get the complete sample code here.

Embed barcode batch separator to your own web application by
Download 30-day free trial

If you have any questions, you can contact our support team at support@dynamsoft.com.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.

Subscribename@email.com