WebTWAIN-Multipage 1.51 Beta ActiveX Control Overview
 

WebTWAIN-Multipage Beta is an ActiveX control that provides for multipage image aquisition from a TWAIN source. It is a beta evolution form our Standard WebTWAIN-Multipage scanning component. WebTWAIN-Multipage V1.50 Beta differs from the standard WebTWAIN in that it adds support for Automatic Document Feeders (ADF), pre-negotiation of the desired images' resolution (dpi), color depth (colour, gray-scale, black and white) and Papersize (A4,B4 etc). It also caters for non-UI scanning, which means it can be used to scan without the intervention of the scanner driver's User Interface. In addition, WebTWAIN-Multipage 1.50 Beta provides a mechanism for enumerating the TWAIN drivers found on the client computer and allows scanning from a specified TWAIN Driver. This is useful if there are multiple TWAIN devices connected to the target system.

WebTWAIN-Multipage Beta 1.50 is Beta software. It has not been fully tested and is not necessarily suitable as a production release. ADF Support was checked against an HPscanjet 5550c. It may or may not work with other ADF Scanners. Further, not all scanners necessarily support pre-negotiation or no-UI scanner.

 
Relevant WebTWAIN-MultiPage 1.50 Beta Control Properties, Methods and Events
The following properties are typically set before image acquisition begins:
Property Height As SingleHeight Read/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 SingleWidth Read/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 IntegerBorderStyle Read/Write Property that determines whether the control is bordered (1) or not (0).
Property Quality As LongQuality This 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 StringFilePath Sets 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 VariantSaveAsPDF This Boolean specifies whether the generated file should be in PDF (true) or TIFF (false) format. Defaults to True.
Property TiffColours As VariantTiffColours String 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 LongTiffInversion On 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).
Property Negotiation As LongNegotiation (New) Read/Write Property that sets whether the control should attempt to pre-negotiate with the TWAIN Driver regarding colour depth, resolution and PaperSize. Valied values are 0 (negotiation disabled) and 1 (negotiation enabled). Defaults to 0 (disabled).
Property PixelType As LongPixelType (New) Read/Write Property that controls the colour depth at which scanning is to occur. Valid values are number between 0 and 3, with the following meaning:
0 : Black and White
1 : 256 Gray Scale
2 : Millions of Colours
3 : 256 Colour Palette
Only relevant if the Negotiation property is set to 1.
Property Resolution As LongResolution (New) Read/Write Property that sets the resolution (dpi) at which images should be acquired. Only relevant if the Negotiation Property is set to 1. Defaults to 100 dpi
Property PaperSize As LongPaperSize (New) Read/Write Property that sets the preferred PaperSize for the scan. Useful in ADF Applications, but we don't really know if it works or not :( PaperSize is a number between 1 and 16. The exact significance of each value can be obtained from the method PaperSizeDescription. Only relevant if the Negotiation property is set to 1. Defaults to 1 (A4-LETTER).
Property ScanSource As LongScanSource (New) Read/Write Property that controls which TWAIN Driver images should be acquired from. Valid values are 0 to the number of TWAIN Drivers on the System. 0 instructs the control to use the default source. Exactly how many TWAIN Drivers are available can be obtained from the TWAINSourceCount and TWAINSourceName methods. Defaults to 0 (default source).
Property ShowUI As LongShowUI (New) Read/Write Property that controls whether TWAIN Driver's User Interface should be shown on starting an acquisition. Valid values are 0 (No UI shown) and 1 (UI shown). Defaults to 1. Note that if Negotiation is 0, then the UI will always be shown.
Property AutoFinish As LongAutoFinish (New) Read/Write Property that controls whether the control should automatically fire the ScanComplete event when scanning has been completed. This is useful in cases where ADF is being used, since the user does not explicity need to click on the Finish button. Setting this to 1 enables AutoFinish, setting to 0 disables AutoFinish. Defaults to 0 (disabled).
Property FullScreen As LongFullScreen (New) Read/Write Property that controls whether the control is to assume fullscreen mode or not. In Fullscreen mode (1), the buttons are not visible and the 4 graphic pages take up the full area of the control. Valid values are 0 (Normal view with buttons) and 1 (FullScreen mode). Defaults to 0.
 
The following information functions provide more information on the control environment and capabilities:
Function TWAINSourceCount() As LongTWAINSourceCount (New) Returns the number of installed TWAIN Sources on the client computer.
Function TWAINSourceName(ByVal X As Long) As StringTWAINSourceName(lngX) (New) Returns the name of TWAIN Source lngX. Valid values for lngX are 1 to TWAINSourceCount
Function TWAINDefaultSource() As StringTWAINDefaultSource (New) Returns the name of the Default TWAIN Source on the client computer.
Sub StartScan()StartScan() (New) Method that can be used to start a scanning process from script. Has the same function as clicking on the control's Scan button.
 
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)Images Read-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.SaveAsPDF = False
  document.X.ScanControl.TiffColours="2"
  document.X.ScanControl.TiffInversion=0
  document.X.ScanControl.Negotiation = 1
  document.X.ScanControl.Resolution = 150
  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,5,0,1">
   </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 5.35 MByte could be downloaded on the first use of the control, dependent on which components are already present on your system)Initial 5.35 MB Download
Distribution CAB File5,621,883 bytes
Standard .EXE Setup Program5,240,830 bytes
 
Purchasing Information

WebTWAIN-Multipage 1.51 Beta is not yet for sale pending complete testing. However, feel free to try it and provide any feedback.

 
Revision History
Aug 1, 2003Released V1.51 with added FullScreen Property and IObjectSafety implemented. The latter now marks the control as Safe for Initialization and Scripting even if installed from the .exe.
Apr 19, 2003Initial Beta Release 1.50
 
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 19 April 2003