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 - Frequently Asked Questions

General questions:

 

Redistribution:

 

Sales:

 

Programming:

 

Web:

 

Databases:

 

 

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

The TWAIN .NET SDK allows to control work of scanners, web or digital cameras and any other TWAIN compatible devices.

 


 

From which parts does the library consist?

The library contains:

  • The following assembly: Vintasoft.Twain.dll
  • Assemblies compiled under .NET 2.0 and 4.0 for AnyCPU, x86 and x64 platforms (\Bin\vX.0\...)
  • Assemblies compiled under WPF 3.5 and 4.0 for AnyCPU, x86 and x64 platforms (\Bin\vX.0\...)
  • Demos compiled under .NET 2.0 and 4.0 for AnyCPU, x86 and x64 platforms (\Bin\vX.0\...)
  • Demos compiled under WPF 3.5 and 4.0 for AnyCPU, x86 and x64 platforms (\Bin\vX.0\...)
  • Documentation file in CHM format (\Documentation\VintaSoft.Twain.chm)
  • Visual Studio .NET 2005-2012 example projects for VB.NET, C# and ASP.NET (\Examples\VS.NET.20XX\...)

 

 

In which programming languages can I use this TWAIN scanning 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 contain the evaluation version?

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 send a message to Customer Support Service 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 of non-web applications. Single Developer license has limitation of 100 copies per year in re-distribution of non-web applications. Server license is limited by only one server domain your web applications may be deployed to. 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 have to contact Customer Support Service in the event your application redistribution count is about to exceed or exceeded 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 royalty free distribution of an application which integrates the SDK redistributable assemblies up to 100 copies in a year.
  • Site license permits 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, 8 OS installed. Server - Windows Server 2003, 2008, 2012 OS installed.

 

 

How can I add the Vintasoft.Twain.DeviceManager component to a form of 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 which allows 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 scanner's user interface?

Here is an example that shows how to acquire images from scanner's automatic document feeder asynchronously:

  [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 acquire images from the device synchronously:

  [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.Devices.CurrentIndex = 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 done 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 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 different Resolution for X and Y direction?

Yes. Here is the sample of code which allows 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 information from the scanner?

This example demonstrates how to get information from scanner 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 color and 16-bit grey images?

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

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

  [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:

  [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:

  [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?

Please read the "Programming => Troubleshooting" article in the documentation.

 

 

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

Please read the "Programming => Troubleshooting" article in the documentation.

 

 

What should I do to add the VintaSoft Twain Component to my web project?

Please read how to deploy web application in the documentation in the "Deploying web application" article.

 

 

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

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

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

  [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 13 here.

 

 

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

If you use VintaSoftTwain.NET SDK in JavaScript you have to 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 7 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 into 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 into 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