Click here to Skip to main content
Click here to Skip to main content

.NET Web Twain

By , 29 May 2005
 

Sample Image - Web_Twain.jpg

Abstract

Simply I want to use scanner in client side in DMS (Document Management System) web application. I have searched the Internet for solution but I found it very expensive for me so I decided to write a free one.

Details

I found some articles in CodeProject like .NET TWAIN image scanner By NETMaster. That's nice. That is my goal:

  1. Rewrite NETMaster's application to be in one Windows form, make it automated and find way to deploy it in web page.
  2. Call this application from your web page.
  3. Upload the acquired image to server in simple way.

step 1:nop

step 2:You can use JavaScript to do it.

<input onclick="javascript:window.open('file:///C:/TZTwain/TZTwain.exe',1);"
           type=button value=Scan>

But this code will not work with Windows XP sp2 :( So use this one:

<input onclick=runApp() type=button value="Scan XP sp2 users" name=button1>
<script language="javascript" type=text/javascript>
function runApp() 
{ 
  var shell = new ActiveXObject("WScript.shell");
  shell.run("c:\\tztwain\\tztwain.exe", 1, true); 
}
</script>

Step 3: You can use FTP or simply web service like me.

Sample App

  1. Configure testScan and FileUploadWS in IIS.
  2. FileUploadWS: Change save location.
    string filePath=Server.MapPath(@"..\testscan\upload\j2.jpg");
  3. TestScan: gives write permission to users (ASP.NET, IWAM and IUSR) at upload folder.
  4. Change web reference in testdotnettwain to localhost. Then build it and ZIP the exe file with winrar and make it sfx (with these options).
    Path=c:\tztwian\tztwain.exe
    Silent=1
    Overwrite=1) then put the tztwain.exe in c:\inetpub\wwwroot\testScan.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Taha Amin
Team Leader http://www.linkdev.com/
Egypt Egypt
Member
B/OSS.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionscanmembermasumeh__7 Jan '12 - 5:32 
i have a web application in asp.net, i want when the user press scan button a picture from scaner scaned and show the picture in IE.
QuestionASP.net application using Twain in c#memberakul12323 Aug '11 - 20:40 
I want to develop a web application using asp.net(C#) that can take an image from a scanner (Microtek: scanmaker 1000XL). when a "Scan" button is clicked then the application will capture the image from the scanner. The scanner is Twain compatible. Can I get any sample codes for this web application. Any help would be appreciable.
 
Platform: windows XP sp3
32 bit
 
I found a sample in the link
.NET Web Twain[^]
But it doesn't work.
GeneralMy vote of 1memberAtenaShirzad21 Aug '11 - 0:47 
very bad
GeneralThis useless article should be removedmemberMember 7509855 Feb '11 - 20:57 
it is 100% useless.
Generalask for helpmemberMember 391195816 Jan '11 - 17:40 
Hi,
Thanx for the code.But i have a question : what should i do to make this code work under windows 2003 server sp2?Is there any way?
thanx
GeneralI feel your pain..memberbjames0218 Jul '10 - 21:21 
I found that .net usercontrols could be hosted in asp.net website via code access security, however, the dll(s) would reside on the server and have to be downloaded. This isn't practicle when you are using a heavy 3rd party library. The trick is to wrap the .net user control in a COM visible activeX object. This requires that browser security settings must be lowered, but it does allow the control to reside on the client.
 
Cheers.
GeneralMultiPage Scaningmembervikica10 Jun '09 - 4:01 
can u please help me how to modify your code to make it work for multi page scaning. Like this ArrayList pics returns count 1.
GeneralRe: MultiPage Scaningmembervikica12 Jun '09 - 2:37 
ok i found it capacity to -1
GeneralRe: MultiPage Scaningmemberstr_test3 Jul '10 - 6:53 
Can you please tell me on which class I have to set the capacity to -1 for multiple-page scanning? Any information you can provide will be appreciated. Thank you.
GeneralRe: MultiPage ScaningmemberTaha Amin3 Jul '10 - 10:36 
this is very old article, kindly use WIA
GeneralhelpmemberTravis R9 Mar '09 - 9:39 
I'm looking for a good web based TWAIN scanning solution, and this could be what I'm looking for. However, I'm having trouble setting it up. Do I need to set each component up as a separate site in IIS?
Generalaccess denied errormemberforgoats22 Nov '08 - 4:03 
I get an access denied error for the following line in testscan
 
window.open('file:///C:/TZTwain/TZTwain.exe',1);
 
I've given all the permisions I can to this file, but I still get it. Any ideas?
 
Thanks,
Sam
AnswerRe: access denied errormemberOffroad_0112 Dec '08 - 1:00 
I'm guessing you're running Microsoft Windows Vista. If so, the solution has two parts:
 
1) Modify the runApp function in default.aspx (testscan directory) so the javascript reflects the following...
 
<script language="javascript" type="text/javascript">
		function runApp()
		{
		var browser=navigator.appVersion;
		if (browser.indexOf("Windows NT 5.2")>-1)
		{
		runAppXP();
		}
		else if (browser.indexOf("Windows NT 5.1")>-1)
		{
		runAppXP();
		}
		<code>else if (browser.indexOf("Windows NT 6.0")>-1)
		{
		runAppXP();
		}</code>		
                  else
		{
		window.open('file:///C:/TZTwain/TZTwain.exe',1);
		}
		}
 
                  function runAppXP() 
                  { 
                  var shell = new ActiveXObject("WScript.shell");
                  shell.run("c:\\tztwain\\tztwain.exe", 1, true); 
                  }
                  </script>
2) In Internet Explorer, click on Tools -> Internet Options -> Security Tab and then under "Security level for this zone" click Custom Level... Locate the "ActiveX controls and plug-ins" section and then set "Initalize and script ActiveX controls not marked as safe for scripting" to "Prompt" which will force IE to prompt you for approval when an ActiveX control that is not marked as safe (such as WScript) attempts to be called.
GeneralRe: access denied problemmember4hmeT22 Aug '12 - 0:56 
Hi sir..
my os is Win7 and i have all security setting enable for active X and plugins but still not working ..
 
Meanwhile, I have tried on Win XP but again access denied problem ..
 
Please help
GeneralRe: access denied errormemberfarrukhahmedqureshi14 May '10 - 0:55 
My dear brother my OS is XP and i have all security setting enable for active X and plugins but still not working farrukh from pakistan
Generalit's working !!memberOracle500726 Oct '08 - 20:33 
hello mr taha amin.
 
thank u for your god project.
 
its working like engine of benze.
 
MEGSI.
 
Ali Azhdari
Big Grin | :-D
Cool | :cool:
Rose | [Rose]
QuestionHey , Are You Sure This Work friend?memberOracle500720 Oct '08 - 22:33 
hi , i am ali azhdari from iran.
your code dont work.
actualy i must ask about your web service.
if you can give me another helps to do it , i'm be very happy and i must say thank you to you for your god work.
i'm like you have a project but can't buy components, i see it in som place ( use win app to can and transfer to webapp but i must be quick) ,
i need it imeadietly.
thank you.
ali azhdari
QuestionMicrosoft JScript runtime error: Automation server can't create objectmemberFahim_6213 Jun '08 - 20:09 
Hi Friend
 
When i click on scan button this error is activate
 
Microsoft JScript runtime error: Automation server can't create object
 
this error is in this part of program:
 
var shell = new ActiveXObject("WScript.shell");
 
help me to solve this problem
 
thanks alot
 
Fahim_62

AnswerRe: Microsoft JScript runtime error: Automation server can't create objectmemberOffroad_0112 Dec '08 - 1:03 
WORKAROUND:
 
In Internet Explorer, click on Tools -> Internet Options -> Security Tab and then under "Security level for this zone" click Custom Level... Locate the "ActiveX controls and plug-ins" section and then set "Initalize and script ActiveX controls not marked as safe for scripting" to "Prompt" which will force IE to prompt you for approval when an ActiveX control that is not marked as safe (such as WScript) attempts to be called.
GeneralRe: Microsoft JScript runtime error: Automation server can't create objectmemberNitinMakwana9 Feb '10 - 23:11 
hello,
i get same error and apply solution what you have suggested
but it still give same error
GeneralHello Therememberab_dc17 Oct '07 - 1:39 
Hi there , this is mahmoud ramzy , we are Egyptians , Happy Eid to you and your family.
I tried to run your scanning demo , but really not worked.
I'm using asp.net2.0 with Visual Studio 2005
so if you can provide help , please dot it.
I want to scan images and return file path , also run the scanner program at the client side. please help me , please.
thanks again for your co-operation .
Slamo Alikum.

 
Mahmoud Ramzy
Generalhelp mememberpiercarmine20 Sep '07 - 21:35 
I'dont understend like to insert this in my web application. Help me,
thanks
QuestionTo use window application in web applicationmemberkk_upadhyay5 Sep '07 - 0:33 
hi to all,
 
i have a scanning application in vb.net.now i am creating Asp.net web application to do so?
is it possible to use the window application in asp.net web application?
if ,yes .please tell me how to do this?
 
hhhhhhhhhh

QuestionScanning in asp.net web applicationmemberkk_upadhyay5 Sep '07 - 0:26 
hi,
i want ot make a web application in asp.net to scan document by scanner ?
how can i do this?
 
hhhhhhhhhh

General[Document Scanning ]membersamshah51222 May '07 - 19:28 
Hi '
 
I am in the process of developing a web based scanning application using ,ASP.NET c Sharp. I need help, kindly guide me how to implement it.;)
 
Thanks,Smile | :)
 
Ali
 
Life is too short to be counted, enjoy life.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 29 May 2005
Article Copyright 2005 by Taha Amin
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid