Testimonials


Got it downloaded and we will put that to work right away! We purchased a .Net twain control set for a custom written application using cameras about three years ago. We found Vintasoft in an Internet search. When we updating the software, we purchased the newer version that we needed.

Our developer had said it was well written code. Thank you once again.

Peter Philbrick
IT Director | ComCor, Inc.





VintaSoftTwain.NET SDK - FAQ

General questions:

 

Redistribution:

 

Sales:

 

Programming:

 

Web:

 

Databases:

 

 

For which purposes can I use the VintaSoftTwain.NET SDK?

SDK can be used for controlling a work of scanners, web or digital cameras and any other TWAIN devices.

 


 

From which parts does the library consist?

The SDK contains:

  • Vintasoft.Twain.dll file - a 100% .NET assembly
  • Documentation in CHM format (Help\Vintasoft.Twain.chm file)
  • Examples for MS Visual Basic.NET, MS Visual C#, ASP.NET (files in the Examples directory)
  • Demo applications for 32-bit systems (files in Bin\v2.0\x86 and Bin\v4.0\x86 directories)
  • Demo applications for 64-bit systems (files in Bin\v2.0\x64 and Bin\v4.0\x64 directories)

 

 

In which programming languages can I use the Vintasoft.Twain component?

With Single Developer license or Site license you can use component in:

  • Microsoft Visual Studio .NET : Visual Basic, Visual C#, Visual C++, Visual J#
  • Borland Delphi 8.0, Borland C# Builder, Borland C++ BuilderX
  • any other languages which are compatible with .NET Framework.

With Server license you can use component in:

  • Internet Explorer : ASP.NET, JavaScript, VBScript

 

 

What restrictions does the unregistered version contain?

Unregistered version has the following restrictions:

  • nag screen
  • any image can be saved to a disk or uploaded onto server as BMP file
  • only black-white, gray or palette image can be saved to a disk or uploaded onto server as JPEG or TIFF file

All these restrictions are removed in registered version.

 

 

I have problems. What should I do?

Answers to the majority of questions can be found in the documentation or this web site. Please write to our support team to get more help.

 

 

What files do I need to include in the setup package of my program?

You need include only one file: Vintasoft.Twain.dll. This file must be placed in the same folder as the assembly that references it. Make sure that the version you distribute is the version your assembly was compiled with.

 

 

Can I re-distribute the Vintasoft.Twain.dll with my application without royalties?

Yes, this component is royalty free. You pay only for registration one time. Only Vintasoft.Twain.dll can be re-distributed with your application.
Site license has no limitations in re-distribution. Single Developer license has limitation in re-distribution. Server license is not royalty free. Please read the license agreement.

 

 

What to do when my Single developer license application redistribution count is about to exceed 100 copies in a year?

If you own Single developer license you must contact Sales in an event your application redistribution count is about to exceed 100 copies in current year. You'll be provided with an opportunity to upgrade your Single developer license to Site license with 30% discount or to buy additional Single developer license.

 

 

What is the difference between Single developer license and Site license?

  • Single developer license must be used in software development by only one programmer whose name is indicated in the license data.
  • Site license must be used in software development by any programmer who works for a company which name is indicated in the license data.
  • Single developer license may be used in software development on any PC located at any physical address.
  • Site license may be used in software development on any PC located at single physical address (at only one office).
  • Single developer license permits a royalty free distribution of an application which integrates the SDK redistributable assemblies up to 100 copies in a year.
  • Site license permits an unlimited royalty free distribution of an application which integrates the SDK redistributable assemblies.

 

 

May I upgrade my existing Standard edition license to equivalent Standard + WPF edition license?

Yes, please contact Sales and you'll be provided with an opportunity to buy the equivalent Standard + WPF edition license with 70% discount.

 

 

Is there a difference in deploying my application on a desktop PC or on a server?

Yes, there is. Please read the "Deploying" section in this product documentation to understand the difference.

Terms: Desktop PC - Windows XP, Vista, 7 OS installed. Server - Windows Server 2000, 2003, 2008 OS installed.

 

 

How can I add the Vintasoft.Twain.DeviceManager component to a form in my .NET project?

To add VintaSoft.Twain.DeviceManager component to your form you should do the following:

  • Start Visual Studio.NET with your own project
  • Open the main form in design view
  • Open Toolbox pane
  • Right mouse click on the Toolbox pane
  • Select "Customize Toolbox..." menu item from popup menu
  • Open .NET Framework Components tab
  • Click "Browse..." and select Vintasoft.Twain.dll file
  • Find and check the VintaSoft.Twain component in the list
  • Close window using OK button
  • Find and select in the Toolbox pane VintaSoft.Twain.DeviceManager item
  • Place the VintaSoft.Twain.DeviceManager component on the form by selecting control rectangle

 

 

How can I acquire black-white images?

Here is a sample of code for acquiring black-white images only:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  Private Sub AcquireBlackWhiteImages()
      _device.ShowUI = False
      _device.DisableAfterAcquire = True

      ' open the device
      _device.Open()
      ' set necessary pixel type
      _device.PixelType = PixelType.BW

      ' acquire images from device
      _device.Acquire()
  End Sub

 

 

How can I work with ADF without displaying the User Interface?

Here is an example that shows how to asynchronously acquire images from document feeder:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  Private Sub AcquireImagesFromAdf()
      ' set scan settings
      _device.ShowUI = False
      _device.DisableAfterAcquire = True
      _device.Open()
      _device.PixelType = PixelType.RGB
      _device.UnitOfMeasure = UnitOfMeasure.Inches
      _device.Resolution = New Resolution(200, 200)

      ' set document feeder settings
      If _device.DocumentFeeder.Present Then
          _device.DocumentFeeder.Enabled = True
          _device.XferCount = -1

          ' enable duplex if possible
          If _device.DocumentFeeder.DuplexMode <> DuplexMode.None Then
              _device.DocumentFeeder.DuplexEnabled = True
          End If

          ' acquire images from device
          If _device.DocumentFeeder.PaperDetectable Then
              If _device.DocumentFeeder.Loaded Then
                  _device.Acquire()
              End If
          Else
              _device.Acquire()
          End If
      End If
  End Sub

  ' Handler of the ImageAcquired event.
  Private Sub _device_ImageAcquired(ByVal sender As System.Object, _
                                    ByVal e As Vintasoft.Twain.ImageAcquiredEventArgs)
      e.Image.Save("c:\multipage.tif")
  End Sub

  ' Handler of the ScanCompleted event.
  Private Sub _device_ScanCompleted(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs)
      ' do not close the device if UI is used
      If Not _device.ShowUI Then
          _device.Close()
          MsgBox("Scan completed.")
      End If
  End Sub

 

 

Can I hide the user interface and acquire images in modal loop?

Here is an example that shows how to synchronously acquire images from the device:

  [VB.NET]
  Friend Shared Sub Main(args As String())
      Try
          Using deviceManager As New DeviceManager()
              ' open the device manager
              deviceManager.Open()

              ' get reference to the current device
              Dim device As Device = deviceManager.CurrentDevice

              ' open the device
              device.Open()

              ' set acquisition parameters
              device.TransferMode = TransferMode.Memory
              device.ShowUI = False
              device.DisableAfterAcquire = True
              device.PixelType = PixelType.BW

              ' create directory for TIFF file
              Dim directoryForImages As String = _
                  Path.GetDirectoryName(Directory.GetCurrentDirectory())
              directoryForImages = Path.Combine(directoryForImages, "Images")
              If Not Directory.Exists(directoryForImages) Then
                  Directory.CreateDirectory(directoryForImages)
              End If

              Dim multipageTiffFilename As String = Path.Combine(directoryForImages, _
                                                                 "multipage.tif")

              ' acquire image(s) from the device
              Dim acquireModalState1 As AcquireModalState = AcquireModalState.None
              Dim imageIndex As Integer = 0
              Do
                  acquireModalState1 = device.AcquireModal()
                  Select Case acquireModalState1
                      Case AcquireModalState.ImageAcquired
                          ' save image to file
                          device.AcquiredImages.Last.Save(multipageTiffFilename)
                          ' output current state
                          imageIndex = imageIndex + 1
                          Console.WriteLine(String.Format("Image{0} is saved.", _
                                                          imageIndex))

                      Case AcquireModalState.ScanCompleted
                          ' close device and device manager
                          CloseDeviceAndDeviceManager(deviceManager, device)
                          ' output current state
                          Console.WriteLine("Scan completed.")

                      Case AcquireModalState.ScanCanceled
                          ' close device and device manager
                          CloseDeviceAndDeviceManager(deviceManager, device)
                          ' output current state
                          Console.WriteLine("Scan canceled.")

                      Case AcquireModalState.ScanFailed
                          ' close device and device manager
                          CloseDeviceAndDeviceManager(deviceManager, device)
                          ' output current state
                          Console.WriteLine(String.Format("Scan failed: {0}", _
                                                          deviceManager.ErrorString))
                  End Select
              Loop While acquireModalState1 <> AcquireModalState.None
          End Using
      Catch ex As TwainException
          Console.WriteLine("Error: " + ex.Message)
      End Try

      Console.ReadLine()
  End Sub

  ' Close device and device manager.
  Private Shared Sub CloseDeviceAndDeviceManager(deviceManager As DeviceManager, _
                                                 device As Device)
      If device.State = DeviceState.Opened Then
          ' close the device
          device.Close()
      End If

      ' close the device manager
      deviceManager.Close()
  End Sub

 

 

I want to scan only a part of image. How can I do this?

Here is an example that shows how to acquire only the top part of page:

  [VB.NET]
  Private Sub AcquirePartOfImage()
      Using deviceManager As New DeviceManager()
          Try
              ' open the device manager
              deviceManager.Open()

              deviceManager.SelectDevice()

              ' get reference to current device
              Dim device As Device = deviceManager.CurrentDevice

              ' open the device
              device.Open()

              ' set acquisition parameters
              device.ShowUI = False
              device.DisableAfterAcquire = True
              ' set image layout (get only the top half of the page)
              device.UnitOfMeasure = UnitOfMeasure.Inches
              Dim imageLayout As System.Drawing.RectangleF = device.ImageLayout.Get()
              device.ImageLayout.Set(0, 0, imageLayout.Width, imageLayout.Height / 2)

              Dim tiffFilename As String = Path.Combine(Directory.GetCurrentDirectory(), _
                                                        "multipage.tif")

              ' acquire images from device
              Dim acquireModalState1 As AcquireModalState = AcquireModalState.None
              Do
                  acquireModalState1 = device.AcquireModal()
                  Select Case acquireModalState1
                      Case AcquireModalState.ImageAcquired
                          ' save acquired image to multipage TIFF file
                          device.AcquiredImages.Last.Save(tiffFilename)

                      Case AcquireModalState.ScanCompleted, _
                           AcquireModalState.ScanCanceled, _
                           AcquireModalState.ScanFailed
                          ' close the device
                          device.Close()
                          ' close the device manager
                          deviceManager.Close()
                  End Select
              Loop While acquireModalState1 <> AcquireModalState.None
          Catch ex As TwainException
              Console.WriteLine("Error: " + ex.Message)
              Console.ReadLine()
          End Try
      End Using
  End Sub

 

 

How can I select a device without displaying the device selection dialog?

Here is an example that shows how to select a device by name:

  [VB.NET]
  Private Sub SelectDeviceByName(ByVal deviceName As String)
      ' create TWAIN device manager
      Using deviceManager As New DeviceManager()
          ' open TWAIN device manager
          deviceManager.Open()

          ' select the device by device name
          Dim device As Device = Nothing
          For i As Integer = 0 To deviceManager.Devices.Length - 1
              If deviceManager.Devices(i).Info.ProductName = deviceName Then
                  deviceManager.CurrentDeviceIndex = i
                  device = deviceManager.CurrentDevice
                  Exit For
              End If
          Next

          ' throw exception if device is not found
          If device Is Nothing Then
              Throw New ApplicationException("Device is not found.")
          End If

          ' acquire images from the device
          device.Acquire()
      End Using
  End Sub

 


 

How can I disable the progress indicator dialog when I acquire images without UI?

TWAIN standard allows to disable the progress indicator dialog when ShowUI=false. This can be made as follows:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  Private Sub AcquireImagesWithoutUiAndIndicator()
      _device.ShowUI = False
      _device.ShowIndicators = False
      _device.DisableAfterAcquire = True

      ' acquire images from device
      _device.Acquire()
  End Sub

 

 

I want to create my own progress indicator of image scan. Is this possible?

Yes, this is possible if you use a Memory transfer mode - you should use a ImageAcquiringProgress event. Here is an example:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  ' Handler of the Device.ImageAcquiringProgress event
  Private Sub _device_ImageAcquiringProgress(ByVal sender As System.Object, _
                      ByVal e As Vintasoft.Twain.ImageAcquiringProgressEventArgs)
      ProgressBar1.Value = e.Progress
  End Sub

 

 

Can I set a different Resolution in the X and Y direction?

Yes. Here is the sample of code how to set X Resolution to 200 dpi and Y Resolution to 400 dpi:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  Private Sub AcquireBlackWhiteImages()
      _device.ShowUI = False
      _device.DisableAfterAcquire = True

      ' open the device
      _device.Open()
      ' set scan settings
      _device.PixelType = PixelType.BW
      _device.UnitOfMeasure = UnitOfMeasure.Inches
      _device.Resolution = New Resolution(200, 400)

      ' acquire images from device
      _device.Acquire()
  End Sub

 

 

Our organization has a network scanner with ADF and we scan many documents each day. How can we automate our work? We want to save each document in a separate file.

You can use blank page for separation of documents and detect blank page, as delimiter of documents, by the AcquiredImage.IsBlank method. Here is an example:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  Dim _documentCounter as Integer
  ...

  Private Sub AcquireImages()
      ' set scan settings
      _device.ShowUI = False
      _device.DisableAfterAcquire = True
      _device.Open()
      _device.PixelType = PixelType.BW
      _device.UnitOfMeasure = UnitOfMeasure.Inches
      _device.Resolution = New Resolution(300, 300)

      ' set settings of the internal image buffer
      _device.AcquiredImages.Capacity = 1
      _device.AcquiredImages.AutoClean = True
      _device.AcquiredImages.TiffMultiPage = True        
      _device.AcquiredImages.TiffCompression = TiffCompression.Auto

      ' set document feeder settings
      If _device.DocumentFeeder.Present Then
          _device.DocumentFeeder.Enabled = True
          _device.XferCount = -1

          ' enable duplex if possible
          If _device.DocumentFeeder.DuplexMode <> DuplexMode.None Then
              _device.DocumentFeeder.DuplexEnabled = True
          End If

          ' acquire images from device
          If _device.DocumentFeeder.PaperDetectable Then
              If _device.DocumentFeeder.Loaded Then
                  _device.Acquire()
              End If
          Else
              _device.Acquire()
          End If
      End If
  End Sub

  ' Handler of the ImageAcquired event.
  Private Sub _device_ImageAcquired(ByVal sender As System.Object, _
                      ByVal e As Vintasoft.Twain.ImageAcquiredEventArgs)
        If e.Image.IsBlank() Then
            _documentCounter = _documentCounter + 1
        End If
        Try
            e.Image.Save("c:\documents\doc" + Str(_documentsCounter) + ".pdf")
        Catch ex As PdfException
            MsgBox(ex.Message)
        End Try
  End Sub

  ' Handler of the ScanCompleted event.
  Private Sub _device_ScanCompleted(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs)
      ' do not close the device if UI is used
      If Not _device.ShowUI Then
          _device.Close()
          MsgBox("Scan completed.")
      End If
  End Sub

 

 

Can I use patch codes to separate batch jobs? If so, how can I detect the end of batch job?

You can detect batch jobs by using the CAP_JOBCONTROL Capability.
Here is an example for Visual Basic .NET:

  [VB.NET]
  Imports Vintasoft.Twain

  Dim _deviceManager As DeviceManager
  Dim _device As Device
  Dim _jobCounter As Integer = -1

  Private Sub ScanWithJobControlButton_Click(ByVal sender As System.Object, _
                                       ByVal e As System.EventArgs) _
                                       Handles ScanWithJobControlButton.Click
      Try
          ' create and open device manager
          _deviceManager = New DeviceManager(Me)
          _deviceManager.Open()

          ' get reference to current device
          _device = _deviceManager.CurrentDevice
          ' create handlers of events
          AddHandler _device.ImageAcquired, AddressOf _device_ImageAcquired
          AddHandler _device.ScanCompleted, AddressOf _device_ScanCompleted
          AddHandler _device.ScanCanceled, AddressOf _device_ScanCanceled
          AddHandler _device.ScanFailed, AddressOf _device_ScanFailed

          ' set scanning settings
          _device.ShowUI = False
          _device.DisableAfterAcquire = True
          _device.AcquiredImages.Capacity = 1
          _device.AcquiredImages.TiffMultiPage = True
          _device.Open()
          _device.JobControl = JobControl.DetectAndIncludeJobSeparatorAndContinueScanning
          _jobCounter = _jobCounter + 1

          ' acquire images from device
          _device.Acquire()
      Catch ex As TwainException
          MsgBox(ex.Message)
      End Try
  End Sub
 
  Private Sub _device_ImageAcquired(ByVal sender As System.Object, _
                                    ByVal e As Vintasoft.Twain.ImageAcquiredEventArgs)
      If _device.EndOfJob Then
          _jobCounter = _jobCounter + 1
      Else
          Try
              e.Image.Save("c:\job" + Str(_jobCounter) + ".tif")
          Catch ex As ImageProcessingException
              MsgBox(ex.Message)
          End Try
      End If
  End Sub

  Private Sub _device_ScanCompleted(ByVal sender As System.Object, _
                                    ByVal e As System.EventArgs)
      _device.Close()
      MsgBox("Scan completed.")
  End Sub

  Private Sub _device_ScanCanceled(ByVal sender As System.Object, _
                                   ByVal e As System.EventArgs)
      _device.Close()
      MsgBox("Scan canceled.")
  End Sub

  Private Sub _device_ScanFailed(ByVal sender As System.Object, _
                                 ByVal e As Vintasoft.Twain.ScanFailedEventArgs)
      _device.Close()
      MsgBox("Scan failed: " + e.ErrorString)
  End Sub

 

 

Can I save acquired images to PDF document?

Yes, you can do this. Acquired images can be saved to a new PDF document or added to an existing PDF document.
Here is an example for VB.NET:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  ' set settings of PDF document
  _device.AcquiredImages.PdfMultiPage = True
  _device.AcquiredImages.PdfDocumentInfo.Author = "VintaSoft Ltd."
  _device.AcquiredImages.PdfDocumentInfo.Title = "Documents acquired from " + _
                                                 _device.Info.ProductName
  _device.AcquiredImages.PdfDocumentInfo.Creator = "VintaSoftTwain.NET SDK"
  _device.AcquiredImages.PdfDocumentInfo.ModificationDate = DateTime.Now
  ' save the first acquired image as new PDF document
  _device.AcquiredImages(0).Save("c:\test.pdf")
  ' add the second acquired image to existing PDF document
  _device.AcquiredImages(1).Save("c:\test.pdf")
  ' add the third acquired image to existing PDF document
  _device.AcquiredImages(2).Save("c:\test.pdf")

 

 

How can I retrieve an extended image info from the scanner?

This example demonstrates how to get information about barcodes found on acquired image:

  [VB.NET]
  Private Sub GetExtendedImageInfo()
      Using deviceManager As New DeviceManager()
          Try
              ' open the device manager
              deviceManager.Open()

              deviceManager.SelectDevice()

              ' get reference to current device
              Dim device As Device = deviceManager.CurrentDevice

              ' open the device
              device.Open()

              ' set acquisition parameters
              device.ShowUI = False
              device.DisableAfterAcquire = True

              ' specify that image info is necessary
              device.ExtendedImageInfo.Add(New _
                     ExtendedImageInfo(ExtendedImageInfoId.BarcodeCount))
              device.ExtendedImageInfo.Add(New _
                     ExtendedImageInfo(ExtendedImageInfoId.BarcodeType))
              device.ExtendedImageInfo.Add(New _
                     ExtendedImageInfo(ExtendedImageInfoId.BarcodeTextLength))
              device.ExtendedImageInfo.Add(New _
                     ExtendedImageInfo(ExtendedImageInfoId.BarcodeText))

              Dim tiffFilename As String = Path.Combine(Directory.GetCurrentDirectory(), _
                                                        "multipage.tif")

              ' acquire images from device
              Dim acquireModalState1 As AcquireModalState = AcquireModalState.None
              Do
                  acquireModalState1 = device.AcquireModal()
                  Select Case acquireModalState1
                      Case AcquireModalState.ImageAcquired
                          ' save acquired image to multipage TIFF file
                          device.AcquiredImages.Last.Save(tiffFilename)

                          Dim barcodeCount As ExtendedImageInfo = device.ExtendedImageInfo(0)
                          If barcodeCount.Items IsNot Nothing Then
                              If barcodeCount.Items.Length > 0 Then
                                  If barcodeCount.Items(0) > 0 Then
                                      Dim barcodeType As ExtendedImageInfo = _
                                                         device.ExtendedImageInfo(1)
                                      Dim barcodeTextLength As ExtendedImageInfo = _
                                                               device.ExtendedImageInfo(2)
                                      Dim barcodeText As ExtendedImageInfo = _
                                                         device.ExtendedImageInfo(3)
                                      Dim infoString As String
                                      For i As Integer = 0 To barcodeCount.Items(0) - 1
                                          infoString = ""
                                          If barcodeType.IsValid Then
                                              infoString = "BarcodeType=" + _
                                                            barcodeType.Items(i) + " "
                                          Else
                                              infoString = "BarcodeType=Undefined "
                                          End If
                                          If barcodeText.IsValid Then
                                              infoString = "BarcodeText='" + _
                                                           barcodeText.StringItems(i) + "'"
                                          Else
                                              infoString = "BarcodeText=Undefined "
                                          End If
                                          Console.WriteLine(infoString)
                                      Next
                                  End If
                              End If
                          End If

                      Case AcquireModalState.ScanCompleted, AcquireModalState.ScanCanceled, _
                                                            AcquireModalState.ScanFailed
                          ' close the device
                          device.Close()
                          ' close the device manager
                          deviceManager.Close()
                  End Select
              Loop While acquireModalState1 <> AcquireModalState.None
          Catch ex As TwainException
              Console.WriteLine("Error: " + ex.Message)
              Console.ReadLine()
          End Try
      End Using
  End Sub

 

 

Can I acquire 48-bit images?

Yes. VintaSoftTwain.NET SDK allows to acquire 48-bit color images or 16-bit gray images if Memory transfer mode is used.

Here is an example that demonstrates how to acquire 48-bpp color image without UI from scanner:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  _device.Open()
  _device.PixelType = PixelType.RGB
  _device.BitDepth = 16 ' 16 - for Epson scanners, 48 - for Canon scanners
  _device.Acquire()


Here is an example that demonstrates how to acquire 24-bpp color image without UI from scanner:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  _device.Open()
  _device.PixelType = PixelType.RGB
  _device.BitDepth = 8 ' 8 - for Epson scanners, 24 - for Canon scanners
  _device.Acquire()


Here is an example that demonstrates how to acquire 16-bpp gray image without UI from scanner:

  [VB.NET]
  Dim _device As Vintasoft.Twain.Device
  ...

  _device.Open()
  _device.PixelType = PixelType.Gray
  _device.BitDepth = 16
  _device.Acquire()

 

 

Can I create predefined session setup for my high-volume scanner?

Yes, SDK allows to load/save predefined session setups for mid- and high-volume scanners.

Here is an example that demonstrates how to save the current device settings to a file:

  [VB.NET]
  ...
  _device.Open()
  Dim fs As FileStream = New FileStream("scanner-setup.xml", FileMode.Append, _
                                        FileAccess.Write)
  _device.SaveSettings(fs)
  fs.Close()
  ...


Here is an example that demonstrates how to load previously saved device settings into the device:

  [VB.NET]
  ...
  _device.OpenDataSource()
  Dim fs As FileStream = New FileStream("scanner-setup.xml", FileMode.Open, _
                                        FileAccess.Read)
  _device.LoadSettings(fs)
  fs.Close()
  _device.Acquire()
  ...

 

 

I receive "Cannot initialize the device manager" message when I open the device manager. How to solve this problem?

You have to:

  • check that TWAIN DSM is installed in the system using the DeviceManager.IsTwainAvailable property
  • specify path to TWAIN DSM using the DeviceManager.TwainDllPath property
  • change version of TWAIN DSM using the DeviceManager.IsTwain2Compatible property.

TWAIN Data Source Manager (DSM) v1.X is TWAIN_32.DLL, normally this file located in "C:\Windows\" directory and included in distributive package of all 32-bit versions of Windows.

TWAIN DSM v2.X for 32-bit systems consists from 2 files: TWAINDSM.DLL and TWAINDSM32.MSM. This DSM is NOT included in distributive package of Windows. In 32-bit systems DSM files must be placed in "C:\Windows\System32\" directory. In 64-bit systems DSM files must be placed in "C:\Windows\SysWow64\" directory.

TWAIN DSM v2.X for 64-bit systems consists from 2 files: TWAINDSM.DLL and TWAINDSM64.MSM. This DSM is NOT included in distributive package of Windows. In 64-bit systems DSM files must be placed in "C:\Windows\System32\" directory.

Latest version of TWAIN DSM 2.X can be found here: http://www.twain.org or http://sourceforge.net/projects/twain-dsm/files/.

 

 

I cannot see devices in TWAIN selection dialog of my application but I can see devices in other applications. Why?

You can compile your application with version 7.0 and higher of VintaSoftTwain.NET SDK in "Any CPU" mode and your application will:

  • work in x32 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
  • work in x64 systems with TWAINDSM.DLL (x64)

You can compile your application with version 7.0 and higher of VintaSoftTwain.NET SDK in "x86" (WOW) mode and your application will:

  • work in x32 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)
  • work in x64 systems with TWAIN_32.DLL or TWAINDSM.DLL (x32)

You can compile your application with version 7.0 and higher of VintaSoftTwain.NET SDK in "x64" mode and your application will:

  • NOT work in x32 systems
  • work in x64 systems with TWAINDSM.DLL (x64)

We recommend use of "x86" mode because all scanners have x32 TWAIN drivers but only new and professional scanners have native x64 TWAIN drivers.

 

 

What steps should I make to add the VintaSoft.Twain Component to my web project?

On Server side you must do the following:

  • Place your web application with VintaSoft.Twain assembly (Vintasoft.Twain.dll file) on to the server.
  • Use the following code in your web page:

    < OBJECT ID="TwainDeviceManager" WIDTH=1 HEIGHT=1
    CLASSID="http://your-server/path-on-server/Vintasoft.Twain.dll#Vintasoft.Twain.DeviceManager"
    CODEBASE="http://your-server/path-on-server/Vintasoft.Twain.dll#version=7,0,0,1">
    < /OBJECT >

    Correct number of version is very important. With wrong version number your customers will download the assembly each time when they will open your web page.

  • Register your web application on ASP.NET server (for more info please read this Microsoft TechNet article)
  • The subfolder where you plan to store images must be granted write privileges to Everyone.


On Client side you must do the following:

  • .NET Framework 2.0 must be installed.
  • Internet Explorer 6.0 and higher or Mozilla Firefox 3.0 and higher with IE Tab Plug-in must be installed.
  • Your site must be added as trusted in security policy of .NET Framework 2.0.

    You can do this as follows:

    • Open the Microsoft .NET Framework Configuration from Control Panel | Administrative Tools
    • Select Runtime Security Policy | Machine | Code Groups | All_Code
    • Right click All_Code and select New to create a new code group
    • Name the code group My_Web_Site
    • Choose the Site condition for the code group
    • Set the Site name as my_web_site.com
    • Assign a Permission Set to the Code Group as Full Trust
    For more information about .NET security policies, please read this MSDN article.

    Important: Only assembly compiled under .NET 2.0 can be used in web application. Assembly compiled under .NET 4.0 cannot be used in web application because .NET 4.0 does not allow to use WinForms controls in Internet Explorer.

  • Your web site must be added to the Trusted Zone in Internet Explorer 8.0 and higher.

    You can do this as follows:

    • Open Internet Explorer and go to "Tools => Internet Options" menu, a window will open.
    • Click the "Security" tab and choose the "Trusted Sites" icon. Click on the button "Sites", a window will open.
    • Enter your web site in the line provided. Remove the check by the entry "Require server verification (https:)...." if this is necessary. Click the "Add" button.
    • Click on the "Close" button. You web site is now added to the list of trusted sites.
    For more information, please read How Internet Explorer determines permissions for .NET Framework assemblies.

 

 

I want to create a script on my website which would automatically configure .NET Framework security settings for my web server, allowing me to avoid complex configurations routines for the end user. What should I do?

You can create a script which will execute this command:


caspol.exe -q -machine -addgroup All_Code -site www.my-company.com FullTrust
-name VSTwain_MyCompany_Site
-description "This permission set grants the right to use VintaSoftTwain.NET SDK on www.my-company.com."

 

 

I have a message "Your .NET Framework Security settings must be configured to run the components in your browser" when I run my web application. What did I make wrong?

First of all you should set a .NET Framework policy as described here.

Next you should check which version of Vintasoft.Twain.dll you use (for example, 7.0.0.1).

Further you should set an OBJECT object in your web page correctly. Correct version number is very important!

Here is an example:

< OBJECT ID="TwainDeviceManager" WIDTH=1 HEIGHT=1
CLASSID="http://your-server/path-on-server/Vintasoft.Twain.dll#Vintasoft.Twain.DeviceManager"
CODEBASE="http://your-server/path-on-server/Vintasoft.Twain.dll#version=7,0,0,1">
< /OBJECT >

It's all that you should do.

 

 

Can I scan images and upload them to the server in intranet application with integrated windows authentication?

Yes, library allows to use any authentication methods supported by .NET Framework.

The following example shows how to use authentication information of the currently logged on user:

  [VB.NET]
  Dim _httpUpload As Vintasoft.Http.HttpUpload
  ...

  _httpUpload.Url = "http://localhost/vstwaindemo/imageupload.aspx"
  _httpUpload.UseDefaultCredentials = True
  ...


The following example shows how to use multiple authentication information:

  [VB.NET]
  Dim _httpUpload As Vintasoft.Http.HttpUpload
  ...

  Dim myCache As New CredentialCache()
  myCache.Add(New Uri("http://www.my-web-server.com/"), "Basic", _
              New NetworkCredential(UserName, SecurelyStoredPassword))
  myCache.Add(New Uri("http://www.my-web-server.com/"), "Digest", _
              New NetworkCredential(UserName, SecurelyStoredPassword, Domain))
  _httpUpload.Credentials = myCache
  ...

 

 

Can I scan images and upload them to the server in web application with Cookieless Forms authentication?

Yes, you can do this, please see example 8 and 9 here.

 

 

How to acquire images from scanner, save acquired images as PDF stream and upload to the server in JavaScript?

If you use VintaSoftTwain.NET SDK in JavaScript you must know that:

  • Indexer of class cannot be accessed from JavaScript, i.e. line "device.AcquiredImages[0]" is not correct in JavaScript
  • JavaScript does not know anything about the ImageFileFormat enumeration. Here are constants of ImageFileFormat enumeration: BMP - 0, JPEG - 1, TIFF - 2, PNG - 3, GIF - 4, PDF - 5.
The following example shows how to save acquired images as PDF stream into memory and upload PDF stream to the server (after all images are acquired):

  [JavaScript]
  ...

  // acquire image(s) from the device
  var acquireModalState;
  var acquireStatusString = "Scan canceled";
  var mem;
  var firstImage = true;
  do
  {
    acquireModalState = device.AcquireModal();
	      
    // image acquired
    if (acquireModalState == 2)
    {
      if (firstImage)
      {
        // get the first image as PDF stored in the memory
        mem = device.AcquiredImages.Last.GetAsStream(5);
        firstImage = false;
      }
      else
      {
        // add image to PDF stored in the memory
        device.AcquiredImages.Last.SaveToStream(mem, 5);
      }
    }
	      
    // scan completed
    else if (acquireModalState == 3)
    {
      acquireStatusString = "Scan completed";

      // upload data from the memory stream (mem) to the server
      ...
    }

    // scan failed
    else if (acquireModalState == 4)
      acquireStatusString = "Scan failed";

    // scan canceled
    else if (acquireModalState == 5)
      acquireStatusString = "Scan canceled";
  }
  while (acquireModalState != 0)

  ...

 

 

Can I store acquired images into a table of MS SQL server?

Yes, you can do this, please see example 3 here.

 

 

I want to store acquired images as PDF documents in database. Can I do this?

Yes, you can save acquired image(s) to a stream and further save stream data to database.

Here is an example that shows how to save each acquired image as a separate PDF document in a stream:

  [VB.NET]
  Dim mem As MemoryStream = _device.AcquiredImages(0).GetAsStream(ImageFileFormat.PDF)


And here is an example that shows how to save all acquired images as a single PDF document in a stream:

  [VB.NET]
  Dim mem As MemoryStream = _device.AcquiredImage(0).GetAsStream(ImageFileFormat.PDF)
  Dim i As Integer
  For i = 1 To _device.AcquiredImages.Count - 1
      _device.AcquiredImages(i).SaveToStream(mem, ImageFileFormat.PDF)
  Next i