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

.NET Web Twain

, 29 May 2005
Rate this:
Please Sign up or sign in to vote.
Web twain.

Sample Image - Web_Twain.jpg


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.


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="'file:///C:/TZTwain/TZTwain.exe',1);"
           type=button value=Scan>

But this code will not work with Windows XP sp2 Frown | :( 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("");"c:\\tztwain\\tztwain.exe", 1, true); 

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).
    Overwrite=1) then put the tztwain.exe in c:\inetpub\wwwroot\testScan.


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
Egypt Egypt
Senior Development Manager, with 11 years of experience. Focused on design/developing/delivery B/OSS modules to satisfy customer/business requirements in accordance to TM Forum's TAM/SID framework. Excellent communication and interpersonal skills, flexibility, ability to adjust to new people and situations, strong problem solving skills and willing to work effectively and efficiently. Gained additional leadership skills such as: - High effective mentorship and coaching - Clearly communication and solutions sharing with my team - Decision making
Follow on   Twitter   LinkedIn

Comments and Discussions

SuggestionUse a 3rd party TWAIN ActiveX / Plugin for easier or quicker deployment PinmemberWindy Liu13-Oct-14 21:08 
GeneralIt's working fine Pinmembermkrishnan605-Sep-13 3:17 
GeneralRe: It's working fine Pinmembersandeep7589-Dec-14 7:09 
Questionscan Pinmembermasumeh__7-Jan-12 6:32 application using Twain in c# Pinmemberakul12323-Aug-11 21:40 
GeneralMy vote of 1 PinmemberAtenaShirzad21-Aug-11 1:47 
GeneralThis useless article should be removed PinmemberMember 7509855-Feb-11 21:57 
Generalask for help PinmemberMember 391195816-Jan-11 18:40 
GeneralI feel your pain.. Pinmemberbjames0218-Jul-10 22:21 
GeneralMultiPage Scaning Pinmembervikica10-Jun-09 5:01 
GeneralRe: MultiPage Scaning Pinmembervikica12-Jun-09 3:37 
GeneralRe: MultiPage Scaning Pinmemberstr_test3-Jul-10 7:53 
GeneralRe: MultiPage Scaning PinmemberTaha Amin3-Jul-10 11:36 
Generalhelp PinmemberTravis R9-Mar-09 10:39 
Generalaccess denied error Pinmemberforgoats22-Nov-08 5:03 
AnswerRe: access denied error PinmemberOffroad_0112-Dec-08 2:00 
GeneralRe: access denied problem Pinmember4hmeT22-Aug-12 1:56 
GeneralRe: access denied problem Pinmembersandeep75810-Dec-14 16:31 
GeneralRe: access denied error Pinmemberfarrukhahmedqureshi14-May-10 1:55 
Generalit's working !! PinmemberOracle500726-Oct-08 21:33 
QuestionHey , Are You Sure This Work friend? PinmemberOracle500720-Oct-08 23:33 
QuestionMicrosoft JScript runtime error: Automation server can't create object PinmemberFahim_6213-Jun-08 21:09 
AnswerRe: Microsoft JScript runtime error: Automation server can't create object PinmemberOffroad_0112-Dec-08 2:03 
GeneralRe: Microsoft JScript runtime error: Automation server can't create object PinmemberNitinMakwana10-Feb-10 0:11 
GeneralHello There Pinmemberab_dc17-Oct-07 2:39 
Generalhelp me Pinmemberpiercarmine20-Sep-07 22:35 
QuestionTo use window application in web application Pinmemberkk_upadhyay5-Sep-07 1:33 
QuestionScanning in web application Pinmemberkk_upadhyay5-Sep-07 1:26 
General[Document Scanning ] Pinmembersamshah51222-May-07 20:28 
GeneralCross browser issue PinmemberJavad Mehmood22-May-07 3:41 
QuestionNo Gui PinmemberAtwal Darshan15-Feb-07 3:39 
GeneralScan Using ADF PinmemberAtwal Darshan15-Feb-07 3:33 
Questiongetting Image PinmemberPaulo Bucho20-Dec-06 2:47 
GeneralDetection problem Pinmemberajlaluan25-Aug-06 18:51 
GeneralRe: Detection problem [modified] PinmemberTaha Zayed26-Aug-06 6:51 
GeneralRe: Detection problem [modified] Pinmemberajlaluan26-Aug-06 23:52 
GeneralShell Pinmemberzhinoos23-Aug-06 23:41 
GeneralAutomation server can't PinmemberCalito26-Jul-06 8:54 
AnswerRe: Automation server can't create object PinmemberOffroad_0112-Dec-08 1:25 
GeneralRe: Automation server can't create object PinmemberSafiuddin Ansari23-Sep-09 2:51 
Generalexception in txtwain.exe PinmemberKHALIYA4-Jul-06 3:21 
dear sir,
i am using your ocx but there is an error '' in ocx
where as it works well in
so pls help me
and thanks for providing the open source code.
will u pls tell me how can i develop my own ocx.
GeneralScanner Pinmemberghannam12-Jun-06 2:42 
GeneralNot closing application Pinmemberi0002471-Jun-06 2:25 
GeneralRe: Not closing application Pinmembermroginski3-Sep-08 5:01 
Generalscan thru asp Pinmemberxlt20-May-06 7:33 
Generalnice solution----problem with the resolution Pinmemberzhidsuk13-Feb-06 10:18 
GeneralNice ! PinmemberTareq_Gamal16-Jan-06 0:43 
Questionwhere is comments? PinmemberTaha Zayed31-May-05 0:46 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

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