Platform : Windows 11, Windows 10, Windows 8, Vista, XP
For Windows Developers who need to capture image from scanner, digital camera or capture card that has a TWAIN device driver with C++ , C#, VB.NET , VB, Delphi, Vfp, MS Access.
Step 1: To install the Scanner SDK ActiveX Control, begin by launching the setup file (http://www.viscomsoft.com/demo/scannersetup.exe). Select the desired installation folder for the Scanner ActiveX and continue with the installation on your development computer.
Step 2: Create New Visual C# Project, select Windows Application.
Step 3: The next step is to install Scanner ActiveX in ToolBox. Select Toolbox, select Components item, right click mouse button, select Choose Items...
Step 4: Select COM Components tab, select Scanner ActiveX Control , click OK.
Step 5: Now you will see the Scanner ActiveX's icon on toolbox, drag it to form.
Step 6: Add Combo box, two buttons , label and textbox on form. Like the following picture.
Step 7: change the name property of textbox to "txttotalpage"
Step 8: In form load event, add the following code to add the image source item to combo box.
short iCount = this.axScanner1.GetNumImageSources();
for (short i = 0; i < iCount; i )
{
this.comboBox1.Items.Add(this.axScanner1.GetImageSourceName(i));
}
if (this.comboBox1.Items.Count > 0)
this.comboBox1.SelectedIndex = 0;
Step 9: add the following code in Scan button click event , assume your scanner support Auto Feeder, if not set FeederEnabled = false, make sure you set BufferResizeMode = false , we need keep the barcode quality , so do not resize the buffer.
this.axScanner1.SelectImageSourceByIndex((short)this.comboBox1.SelectedIndex);
this.axScanner1.FeederEnabled = true;
this.axScanner1.DPI = 200;
this.axScanner1.SetCaptureArea(0, 0, 0, 0);
this.axScanner1.BufferResizeMode = false;
this.axScanner1.Scan();
Step 10: select the Scanner Control, Click Event icon in Properties Windows, double EndScan Event to add the EndScan Event hander.
Step 11: In EndScan event handler , add the following code to get the total scanned page to textbox
txttotalpage.Text = this.axScanner1.TotalPage.ToString();
Step 12: Add the following code on "Read Barcodes for All Pages" button click event.
string str1="";
string strTmp = "";
axScanner1.BarCodeReadScanMultiple = true;
axScanner1.BarCodeReadScanWithoutRotation = true;
axScanner1.BarCodeReadScan45Rotation = true;
axScanner1.BarCodeReadScan45CouterRotation = true;
axScanner1.BarCodeReadScan90Rotation = true;
axScanner1.BarCodeReadScanAccuracy = true;
long ibarcodeCount = 0;
long ibarcodeCountforpage = 0;
for (int i = 0; i < axScanner1.TotalPage; i )
{
axScanner1.SetActivePageNo((short)(i 1));
ibarcodeCountforpage = axScanner1.BarCodeReadFullPage();
if (ibarcodeCountforpage < 1)
{
MessageBox.Show("No barcodes found, try scan to high DPI or set the specific area for detect the barcode");
break;
}
for (int j = 0; j < ibarcodeCountforpage; j )
{
strTmp = axScanner1.BarCodeGetType((short)j).ToString() " score:" axScanner1.BarCodeGetScore((short)j).ToString() " value:" axScanner1.BarCodeGetValue((short)j).ToString();
strTmp = strTmp "rn" strTmp;
}
ibarcodeCount = ibarcodeCount ibarcodeCountforpage;
}
str1 = "Total " ibarcodeCount.ToString() " BarCode detected" "rn" strTmp;
MessageBox.Show(str1);
}
Step 13: Now run the project, select the scanner device, click Scan button, after scanned all pages, click "Read Barcodes for All Pages" button
Download the C# How to Read Barcodes from scanned documents sample source code