Scanner SDK ActiveX

Scanner SDK ActiveX

Platform : Windows 10, Windows 8, Vista, Windows 7, 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.

Popular Solution Go   Back

C# - How to Scan multiple documents into PDF

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 button , label and textbox on form. Like the following picture.



Step 7: change the name property of combo box to "ComboBoximageSource" and DropDownStyle property to "DropDownList"

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.ComboBoximageSource.Items.Add(this.axScanner1.GetImageSourceName(i));
            }

  if (this.ComboBoximageSource.Items.Count > 0)
    this.ComboBoximageSource.SelectedIndex = 0;

Step 9: add the following code in Scan button click event

  this.axScanner1.SelectImageSourceByIndex((short)this.ComboBoximageSource.SelectedIndex);
  this.axScanner1.FeederEnabled = 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: change the name property of texbox to "txttotalpage"

Step 12: In EndScan event handler , add the following code to get the total scanned page to textbox 

 private void axScanner1_EndScan(object sender, EventArgs e)
        {
            txttotalpage.Text = this.axScanner1.TotalPage.ToString();
        }

Step 13: Add SaveFileDialog control on form.



Step 14: Add the following on in Save to PDF click event.

 private void button2_Click(object sender, EventArgs e)
        {
            this.saveFileDialog1.Filter = "PDF File (*.pdf)|*.pdf";
            this.saveFileDialog1.DefaultExt = "pdf";

            this.axScanner1.View = 5;

            if (this.saveFileDialog1.ShowDialog(this) == DialogResult.OK)
            {
                bool bResult = this.axScanner1.SaveAllPage2PDF(saveFileDialog1.FileName, true, 1);
                if (bResult)
                {
                    MessageBox.Show("save to " saveFileDialog1.FileName " complete");
                }
            }
       
        }

Step 15: Now run the project, select the image source device, click Scan button, If you need Scan multiple documents, click Scan button few times, then click "Save to PDF" button.