DotImage Knowledgebase

Home : Licensing : WebDeploy : Deploy DotTwain over the Internet with Web Deployment
Q10029 - HOWTO: Deploy DotTwain over the Internet with Web Deployment

The information provided on this page is for DotTwain version 1.0.  Information for web deploy of DotTwain 2.0 or higher can be found here:  http://www.atalasoft.com/kb/article.aspx?id=10163.

 

This topic demonstrates using features built into the .NET Framework to deploy Atalasoft DotTwain over the internet embedded in Internet Explorer.

Client Pre-Requisites

The following pre-requisites must be established on each client's machine before accessing a DotTwain Web-Deploy assembly:

  1. DotTwain requires Full Trust to be set to the Atalasoft strong name or the deployment Site in order for the application to run on the client machine.  You will need to set a Group Policy with the .NET Security settings to allow access to the Site.  If the clients are not controlled with a group policy, they will have to setup the policy themselves with the Microsoft .NET Framework Configuration Wizard located in Adminstrative Tools.
  2. All clients must have the Microsoft .NET Framework 1.1 or higher (version 1.0 has bugs related to Web Deployment).
  3. Internet Explorer 5.5 (or higher) or the windows file explorer must be used to obtain the assemblies from the web.

Embedding DotTwain Directly into IE

Using simple HTML code, you can cause the assembly to be downloaded and installed into the download cache of the client's system.  This is similar the adding an ActiveX component to a web page.  Here is an example that embeds DotTwain directly into IE:

<object id="Twain" classid="Atalasoft.DotTwain.dll#Acquisition" width="1" height="1"></object>

As you can see, the only real difference with a .NET assembly and an ActiveX is the classid parameter.  The first part of that parameter tells the browser where the assembly is located.  If you don't use a path, the assembly is assumed to be in the same folder as the web page.  This is followed by a hash (#) symbol and the name of the class object you want to create, which in this case is Acquisition.

Once the Acquisition object has been created, you can use client-side scripting to call its methods.  The code below displays the 'Select Source' dialog and then acquires an image.

[JavaScript]
document.Twain.ShowSelectSource();
var img = document.Twain.AcquireModal(false);

This acquires a System.Bitmap image which you can send back to the server using the HttpPost object included in the DotTwain assembly.  See our ASP.NET demo for a working example.

Embedding DotTwain Indirectly into IE as a User Control

Embedding DotTwain directly into IE requires the use of scripting, as outlined above.  There are limitations to scripting, and not everyone is adept with it.  We recommend including DotTwain within a user control for the best web deployment scenario, and ease of use.  A typical use of this is to show a "Select Source" button and an "Acquire" button.  To create a user control, start a Windows Control Library project.  The resulting interface might look like this:

This code below uses the above interface, scans an image, and uploads it to a URL using HTTP post as specified by the PostURL property.

[C#]
string _postUrl;
public string PostUrl
{
 get { return _postUrl; }
 set { _postUrl = value; }
}
private void btnSelectSource_Click(object sender, System.EventArgs e)
{
 this.acquisition1.ShowSelectSource();
}

private void btnAcquire_Click(object sender, System.EventArgs e)
{
 this.lblProgress.Text = "Acquiring Image...";
 Bitmap image = this.acquisition1.AcquireModal(false);
 lblProgress.Text = "Uploading Image to Server...";
 lblProgress.Refresh();
 HttpPost postIt = new HttpPost(System.Drawing.Imaging.ImageFormat.Tiff);
 postIt.FormData.Add("Image", image);
 postIt.PostData(this._postUrl);
 lblProgress.Text = "Done!!";
}
[Visual Basic]
Dim _postUrl As String
Public Property PostUrl() As String
 Get 
   Return _postUrl
 End Get
 Set (ByVal Value As String) 
   _postUrl = value
 End Set
End Property
Private Sub btnSelectSource_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
            Handles btnSelectSource.Click
 Me.acquisition1.ShowSelectSource()
End Sub
 
Private Sub btnAcquire_Click(ByVal sender As Object, ByVal e As System.EventArgs) _
            Handles btnAcquire.Click
 Me.lblProgress.Text = "Acquiring Image..."
 Dim image As Bitmap =  Me.acquisition1.AcquireModal(False) 
 lblProgress.Text = "Uploading Image to Server..."
 lblProgress.Refresh()
 Dim postIt As HttpPost =  New HttpPost(System.Drawing.Imaging.ImageFormat.Tiff) 
 postIt.FormData.Add("Image", image)
 postIt.PostData(Me._postUrl)
 lblProgress.Text = "Done!!"
End Sub

Licensing Web Deployment

The Atalasoft.DotTwain.lic file must be in the same folder on your server as the assembly.  An evaluation or normal DotTwain license will work with installations on "localhost" but not in a deployed server environment.  You will have to request a special license file in order to use DotTwain on your server.  This license is tied to the DNS or IP address of the deployment server.  Please send your licensing request to sales@atalasoft.com.

Debugging Assembly Issues

If you're getting an error when trying to use an assembly method, it's most likely because the assembly object wasn't created due to security issues.  One thing you can do is check the exception logs created by Internet Explorer.  You can find them in the Temporary Internet Files folder named "?FusionBindError!name=Atalasoft.DotTwain.dll Atalasoft.Twain.Acquisition".  Drag this file to Internet Explorer or a text editor to read the exception and trace log.  If you use the HttpPost object, it will create it's own exception file as well.

Related Articles
No Related Articles Available.

Article Attachments
No Attachments Available.

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?

poor 
1
2
3
4
5
6
7
8
9
10

 excellent
Tell us why you rated the content this way. (optional)
 
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2013. InstantASP Ltd. All Rights Reserved

preload preload preload