Using Barcode as Separator in Batch Document Scanning

Last Updated on 2018-10-10

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: 

[javascript] // scan documents in a batch
function AcquireImage() {
if (DWObject) {
DWObject.IfDisableSourceAfterAcquire = true; // Scanner source will be disabled/closed automatically after the scan.
DWObject.IfFeederEnabled = true;
DWObject.IfShowUI = false;

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


function OnBarcodeReadSuccess(sImageIndex, result) {
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
if (ProcssedImagesCount == DWObject.HowManyImagesInBuffer) {
ProcssedImagesCount = 0;
* Read the next image
ReadBarcode(sImageIndex + 1);

function OnBarcodeReadFailure(sImageIndex, errorCode, errorString) {

function SaveFile() {
DWObject.IfShowProgressBar = false;
imageArrays = [];
} [/javascript]

Server Side – SaveToFile.aspx:

[csharp]<%@ 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); %>[/csharp]

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe Newsletter

Subscribe to our mailing list to get the monthly update.