WebTWAIN-Multipage ActiveX Control Overview
 

WARNING:WebTWAIN Multipage is deprecated due to changes that Microsoft made to Internet Explorer. It is no longer supported!

WebTWAIN-Multipage is an ActiveX control that provides for multipage image aquisition from a TWAIN source. It is directly derived from our Original WebTWAIN scanning component and a refinement of our discontinued WebTWAIN-Tiff Beta control. WebTWAIN-Multipage differs from the standard WebTWAIN in that it generates a multipage TIFF of PDF file instead of a single JPG image. It also enhances WebTWAIN's functionality by adding FTP capabilities whereby an acquired document can be transferred to an FTP Server.

NEW : WebTWAIN-Multipage V1.50 Beta is now available. This evolution of WebTWAIN contains experimental support for Automatic Document Feeders (ADF), non-UI scanning and pre-negotiation of PageSize, Colour Depth and Resolution. Since the code is Beta, it has its own website until we are happy with its performance. The Beta site can be reached here.

Like the original WebTWAIN, WebTWAIN-Mulipage was specifically designed to be used in combination with an image uploading Webpage. As web-prgrammers, we are all familiar with standard HTML forms in which we expect visitors to enter or select information. This information is normally posted to a server side processing script which extracts form values and does something with it. Typical examples include performing a database search according to specified criteria, the capturing of form information to a database, or the sending of e-mail based on the posted information. At present, HTML Forms can be seen as a core construct in interactive Web-based systems and are in very wide use.

Although HTML forms are a great mechanism, they do not contain functionality to easily capture paper documents. For example, you may be writing a web-based application that requires a signed paper document to be captured. Or perhaps a drawing or a copy of an invoice or receipt. In such applications, the web-programmer would typically allow the user to select a file on his computer through the HTML Form element <INPUT TYPE=FILE>.

The idea is that the user should scan the document, and save it to his/her disk using some or other external scanning program. This scanned image should then be selected in the HTML form by either typing its location on the drive, or by selecting the Browse button to find the file on the drive. When the form is uploaded to the server, the file that the user specified is posted together with the form data. An example of such a typical form is shown on the left.

What the WebTWAIN family of controls allow you to do is capture images from the scanner from within the HTML Form. This means that visitors do not need to start their external scanning software to scan an image, save it to disk and then fill the name of the file into the HTML form. WebTWAIN controls can scan the image, convert it to an applicable format and automatically fill in the location of the file into the <INPUT TYPE=FILE> form element. It's just simply faster and more convenient while retaining compatibility with standard forms-based uploading.


What we have been talking about so far is applicable to all controls in the WebTWAIN family. The original WebTWAIN limited itself to single image scans. In other words, it allowed the scanning of a single page from the scanner. This is fine for many applications where the docment that needs to be uploaded is just a single page. However, in the real world, documents often consist of more than one page.

This is where WebTWAIN-MultiPage comes in. Instead of scanning a single page, WebTWAIN-MultiPage allows you to scan documents that have more than one page. There is no limit on how many pages are scanned. Once the user has completed all the page scans, he/she clicks on a button marked Finish. This causes the control to include all the scanned images into a multipage TIFF or PDF file. The control can then be instructed to place the name of this file into a specific <INPUT TYPE=FILE> form element.

NOTE : Because ActiveX is a Microsoft technology, WebTWAIN controls only work with Internet Explorer under a 32 bit version of Microsoft Windows (i.e Win9x,WinME,WinNT,Win2000 and WinXP)

WebTWAIN and WebTWAIN-Tiff were originally distributed under a free "donations welcomed" mechanism. I thought that people would find the control useful and be willing to contribute to its developments. A handful of generous people actually did make such donations. However, I could count all of these on one hand. Despite thousands of downloads, no further donations materialised. WebTWAIN-Multipage is therefore NOT licensed under this mechanism. The control is fully functional, but displays a Nag Screen when a scan is completed. To get rid of this Nag Screen, please register the control by clicking on the About button and then the Register button.

 
Relevant WebTWAIN-MultiPage Control Properties, Methods and Events
The following properties are typically set before image acquisition begins:
Property Height As SingleHeightRead/Write Property that sets the screen height of the Control. In IE, this unit is in pixels and is write only. For VB, this is in TWIPS.
Property Width As SingleWidthRead/Write Property that sets the screen width of the Control. In IE, this unit is in pixels and is write-only. For VB, this is in TWIPS.
Property BorderStyle() As IntegerBorderStyleRead/Write Property that determines whether the control is bordered (1) or not (0).
Property Quality As LongQualityThis property determines the intermediate JPEG quality value that will be used when compressing individual images. It may assume a number between 0 and 100 and defaults to 60.
Property FilePath As StringFilePathSets the path to which the aquired image will be saved. For example, if you set this to "c:\" then the WebTWAIN control will write the acquired multipage image to the file "c:\scanx.tif". This property defaults to "c:\".
Property SaveAsPDF As VariantSaveAsPDFThis Boolean specifies whether the generated file should be in PDF (true) or TIFF (false) format. Defaults to True.
Property TiffColours As VariantTiffColoursString variable that determines the amount of colours per image in the final TIFF image. Valid values are "2", "16", "256", "16g" (16 colour greyscale), "256g" (256 colour greyscale), "" (no colour reduction)
Property TiffInversion As LongTiffInversionOn some systems, the TIFF produced by the control appears inverted. This Property can be used to instruct the control to invert TIFF colours. Valid values are 0 (for no inversion) or 1 (for inversion).
The following event occurs when the user has completed image acquisition (by clicking on the finish button):
Event ScanComplete(FileName)ScanComplete(FileName)This event is fired when a TWAIN acquisition has successfully been completed. The event provides a parameter that specifies the full filename of the TIFF of PDF File that the control created.
The following methods are meaningful after acquisition:
Function CurrentName() As StringCurrentName()Returns the name of the acquired TIFF or PDF File.
Function FileSize () As LongFileSize()Returns the filesize of the previously acquired document.
Property Images() As Long (read-only)ImagesRead-Only Property that returns the amount of images contained within the multi-page document.
Property ImageWidth (ByVal Imgno AS Long) As Long (read-only)ImageWidth(n)Read-Only Property that returns width (in pixels) of the nth scanned image. The value n is between 1 and the amount of images available. Useful to check whether your user has scanned images that meet your requirements.
Property ImageHeight(ByVal ImgNo As Long) As Long (read-only)ImageHeight(n)Read-Only Property that returns the height (in pixels) of the nth scanned image. The value n is between 1 and the amount of images available. Useful to check whether your user has scanned images that meet your requirements.
Sub PasteName()PasteName()This method will paste the acquired file name to the control's parent window. For Internet Explorer, this will be to the form element that has the focus at the time the method is invoked. This is illustrated in the example below.
Function UploadImage(vServer As Variant, vUserName As Variant, vPassword As Variant, Optional vFTPMode As Variant = 0, Optional vRemoteFileName As Variant = '', Optional vRemoteDirectory As Variant = '') As StringUploadImage(Svr, UName, Passwd, [Mode], [RemoteName], [RemoteDir])Attempts uploading of the acquired TIFF or PDF file to a remote FTP Server. The parameters are:
Svr : FQDN or IP Address of FTP Server
UName : FTP UserName
Passwd : FTP Password
Mode : FTP Transfer Mode (0 = Active (Def), 1 = Passive)
RemoteName : Remote filename (defaults to scanx.tif)
RemoteDir : (No default)

The function returns a string value that is of zero length if the upload was successful. If any errors occurred, then the function return string contains an applicable errormessage.
Sub ClearImage()ClearImages()Clears all images and prepares for a new document scan.
 
Sample HTML code for using the control
 
<HTML>
<HEAD>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub window_onLoad()
  document.X.ScanControl.FilePath = "c:\"
  document.X.ScanControl.Width=300
  document.X.ScanControl.Height=300
  document.X.ScanControl.Quality=100
  document.X.ScanControl.TiffColours="2"
  document.X.ScanControl.TiffInversion=0
End Sub
-->
</SCRIPT>
<TITLE>WebTWAIN-MultiPage Sample</TITLE>
</HEAD>

<BODY BGCOLOR=CYAN>
<CENTER>
<FORM ACTION="myfileuploader.asp" METHOD="POST" ENCTYPE="multipart/form-data" NAME="X">
<TABLE BORDER=1>
<TR>
  <TD>
    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub ScanControl_ScanComplete(FileName)
      Dim ICount
      Dim M
      Dim R 
      Dim Server
      Dim UserName
      Dim Password
      ICount = document.X.ScanControl.Images
      M = "A TIFF Document with " & ICount & " images "
      M = M & "was successfully acquired and saved to "
      M = M & document.X.ScanControl.CurrentName
      M = M & " (" & document.X.ScanControl.FileSize & " bytes)"
      M = M & vbcrlf & vbcrlf
      M = M & "Do you wish to FTP this to a remote FTP Server ?"
      R = MsgBox(M,vbQuestion + vbYesNo,"Please Confirm")
      If R = vbYes Then
        M = "Please enter the FTP Server's IP Address or Name"
        Server = InputBox(M,"Server Address")
        Setver = Trim(Server)
        If Len(Server) > 0 Then
          M = "Please enter your FTP Username"
          UserName = InputBox(M,"UserName")
          UserName = Trim(UserName)
          If Len(UserName) > 0 Then
            M = "Please enter your FTP Password"
            Password = InputBox(M,"Password")
            Password = Trim(Password)
            If Len(Password) > 0 Then
              M = ""
              M = document.X.ScanControl.UploadImage(Server,UserName,Password)
              If Len(M) > 0 Then
                M = "The FTP Transfer Failed with the following error : " & M
                MsgBox M,vbCritical,"FTP Failed"
              Else
                M = "The File was successfully FTP'ed"
                MsgBox M,vbInformation
              End If
            End If
          End If
        End If
      End If

      M = "Do you wish to paste the Filename into the HTML Form ?"
      R = MsgBox(M,vbQuestion + vbYesNo,"Please Confirm")
      If R = vbYes Then	
        document.X.doc.focus()
        document.X.ScanControl.PasteName()
      End If
   End Sub
   -->
   </SCRIPT>
   <OBJECT ID="ScanControl"
   CLASSID="CLSID:812121F2-2491-4445-8750-830CA8D6CFB9"
   CODEBASE="TifScanner.CAB#version=1,0,0,9">
   </OBJECT>
   </TD>
</TR>
<TR>
  <TD>
    <INPUT TYPE=FILE SIZE=20 NAME="doc">
  </TD>
</TR>
</TABLE>
</FORM>
</CENTER>
</BODY>
</HTML>
 
Downloads
 
Sample HTML File (Zip file of the example above)1,343 bytes
Sample of the control in action (Opens in new window - please be patient as around 3.5 MByte could be downloaded on the first use of the control, dependent on which components are already present on your system)Initial 3.51 MB Download
Distribution CAB File3,681,945 bytes
 
Revision History
 
31 Dec 2010WebTWAIN Multipage officially discontinued. Thanks to Microsoft for breaking it with Vista and Internet Explorer 7. Moved to Linux 2 years ago.
Apr 19, 2003Released V1.50 Beta with support for ADF,Pre-negotiation of resolution, colour depth and papersize. Beta site is available here.
Nov 7, 2002Fixed runtime error bug on right clicking on control's image elements. Released updated V1.0.9
Oct 28, 2002Re-Released as WebTWAIN-Multipage V1.08. Adds PDF generation, nag screen and fixed CAB installation.
Oct 28, 2002Terminated WebTWAIN-Tiff Beta.
Feb 25, 2002Updated Release V1.0.7 defines filepath as a variant (instead of string). Also removes wininet.dll from the setup cab.
Dec 19, 2001Updated Release V1.0.5 replaces ImageMagick with TiffDLL for Tiff generation.
Nov 18, 2001Updated Release V1.0.4 to fix failed ImageMagick Installation
on Windows NT4.0
Nov 17, 2001Updated Release V1.0.3 to fix non-functioning TIF colour inversion
Nov 15, 2001Initial Release V1.0.1
 
Build & Resource Information
 
Primary Build Tool Visual Basic 6.0 SP5
TWAIN Library EZTwain 1.06
JPEG Compression Intel® JPEG Library
JPEG Wrapper SaveJPEG Project
PDF Support PDF ImageStream
Scaled Image Display ImageScaler 6.4
TIFF Support TiffDLL V1.01
 
Disclaimer
 

This ActiveX Control is provided as is and without any guarantees or promises. You use it entirely at your own risk. It was written with care and was not designed to do anything clandestine or trojan like. It does nothing but try and talk to a TWAIN source, convert acquired images to a mutipage TIFF or PDF (named scanx.tif or scanx.pdf) in the directory as specified. However, it cannot be assumed to be bug or error free. You also cannot hold me responsible if it crashes your machine, corrupts your registry, destroys your Micosoft Visual Studio 6.0 SP5 (which it was built on) or starts World War III.

 
Contact Information
 

If you wish to mail me any comments, feel free to do so at stefan@internext.co.za

 
accesses since 15 November 2001