Scanning documents

  
Hi there,
We have the need to connect to a scanner (TWAIN compatible) and direct the scanner from the browser (like start scanning, import PDF as binary). We have seen some commercial available TWAIN comptable SDK's, and like to know how to connect OutSystems to an ActiveX or import actions from the SDK through IntegrationStudio.
Your help is appreciated. We are currently on platform version 8.
Saludos,
Wilko



Wilko,

Look at this https://sarafftwain.codeplex.com/
Perhaps this a bit more suited and easier.



Hi,
We are trying to get it to work, however after importing the Saraff.Twain.dll in Integration Studio the compile fails because of a required .Net2.0 where we have . We got stuck with installing .Net2.0 on our server where we have.Net4.5.1. It seems the server does not allow the Role Management Tool to install 2.0. We'll keep trying.
Wilko

do you include the dll in the extension and publish it along?
you can check it in the sources-tab when you opened the extension in integration-studio

I have included the TwainDSM.dll ( the 32 bit version) through integration studio:
The steps I did are the following:

1. I have copied the TwainDSM.DLL into the bin directory of the .net solution.
2, right click on the dll and selected include in Extention in integration studio
3. integration studio has created a new directory structure: ng\source\NET\Bin\TWAINDSM.dll
4. I have verified the extention.
5. published to our outsystems environment.

The structure in integration studio looks as follows:



After that I refeshed references on the test project I'm using and debugged through the actions and I'm still getting the same error: "Cann't load DSM"  at the same locations for both actions.

Alexei
hi, i am trying to isolate the issue, when i ran the source in visual studio ,the debugger fired an exception at the openDSM() method.here is a snapshot


Tmlewin,

When I installed the scanner locally on my laptop and created a website project in Visual studio I could command the scanner without any issues.
the steps I followed was the following:

1. Imported the saraff.twain.dll , and added the axhost.cab into the project as resources.
2.  I put a button on the page
3. add in the events of the button click an object creation  twain32 scanner = new twain32() (just as an example now)
4. Then i called the acquired function and the scanners scan software was triggered.

This means that the scanner can be commanded, 
This means that there is something missing either in the extention that needs to be included or something needs to be installed on the IIS server( Outsystems platforn server).

Thanks for your feedback Tmlewin and mr. J, your help is much appreciated in this matter.

Alexei


hi Guys,

I went to check the web example of Saraff and in the page on load it uses a java script code to load the axhost:

example Saraff:
function LoadScanComponent() {
        try {
          if (AxHost && AxHost.object) {
            req.innerHTML = "";
            AxHost.WorkingDirectory = location.href.substr(0, location.href.lastIndexOf("/"));
            AxHost.ApplicationTypeName = "Saraff.Twain.WebSample.dll!Saraff.Twain.WebSample.ScanComponent";
            AxHost.AddComponentParameter(AxHost.WorkingDirectory + "TwainHandler.ashx")
            AxHost.Load();

            FillDS();
            SelectDS();
          }
        } catch (ex) {
          alert(ex.message);
        }
      }

my code:

function LoadScanComponent(txtid) {
        try {
          if (AxHost && AxHost.object) {
             alert("got into the if of AXHost"); 
            req.innerHTML = "";
            AxHost.WorkingDirectory = location.href.substr(0, location.href.lastIndexOf("/"));
            AxHost.ApplicationTypeName = "Saraff.Twain.dll";
            AxHost.AddComponentParameter(AxHost.WorkingDirectory + "TwainHandler.ashx")
            AxHost.Load();
            FillDS(txtid);
            //SelectDS();
          }
        } catch (ex) {
          alert(ex.message);
        }
      }
      
    
       function FillDS(txtid) {
          
           var text = document.getElementbyId(txtid);
           _method = AxHost.CreateMethodDescriptor("GetSourceProductName");
          _method.AddParam(sourceIndex, 1);
            text.innerHTML =  AxHost.PerformMethod(_method);
           
      }

So I have put a similar code in the javascript block of the page in Outsystems. but it gives me an error: " axhost is undefined".  I pressume this is that the axhost needs to be installed, because when you run the sample of Saraff it requires to install a plugin ( activeX maybe?? or is it a OCX??).  

my question now is how do I do like a deployment to install that activeX in the browser?

I have included the  saraff.axhost.cab, saraff.axHost.inf and saraff.axhost.setup.msi as a resource in the espace  and I have set the deploy action for each of them to  "Deploy to Target Directory".

I debugged the java script and it fails at the moment of checking for the axHost (if (AxHost && AxHost.object) ).

Can somebody shed some light on this, thanks in advance.

Alexei

 

I'm not sure what you are trying to achieve here. It seems you are installing a server component, but want to use the scanner locally? That won't work.
Kilian Hekhuis,

thanks for your response.   
That is why I'm using the javascript to command the scanner.in the example the axhost is an object on the page. so I think I need to create an extention with the axHost.dll and reference it and create the axhost object. in order to use it. 

I will try that one.

on codeplex site there is a websample, maybe you can check that out as well.
otherwise there is also a commercial one. http://www.dynamsoft.com/Downloads/WebTWAIN-Sample-Download.aspx
I dunno why I forgot about that, but indeed, it's not that 1-2-3 to gain access to a local device with the browser.
J.

Thanks for your reply, based on the websample I'm trying to replicate it in Outsystems.  the steps that I saw in the web sample are as follows.

1. There is an axhost object on the screen (index2.htm)
  
<object id="AxHost" name="AxHost" classid="clsid:7067A712-CDFD-4780-B6C0-B8F68A9BA84F" codebase="Saraff.AxHost.cab"></object>
    <script language="javascript" type="text/javascript">
      function AxHost::FireEvent(eventId) {
        switch(eventId.EventName){
          case "Uploading":
            Uploading();
            break;
          case "Uploaded":
            Uploaded(eventId.GetParam("Name"));
            break;
          case "Error":
            Error(eventId.GetParam("Message"));
            break;
        }
      }
    </script>

2. On the body onload event. it checks for this object and assign the working directory and then it opens the DataSource of the scanner.

<body onload="LoadScanComponent()">

The function being called is a javascript function that i have placed in the javascript section of the Homepage.aspx in Outsystems
(someone on codeplex noted that in front of the TwainHandler.ashx there is a backslash missing, but the code doesn't even get there)

<script language="javascript" type="text/javascript">
      function LoadScanComponent() {
        try {
          if (AxHost && AxHost.object) {
            req.innerHTML = "";
            AxHost.WorkingDirectory = location.href.substr(0, location.href.lastIndexOf("/"));
            AxHost.ApplicationTypeName = "Saraff.Twain.WebSample.dll!Saraff.Twain.WebSample.ScanComponent";
            AxHost.AddComponentParameter(AxHost.WorkingDirectory + "/TwainHandler.ashx")
            AxHost.Load();
 
            FillDS();
            //SelectDS();
          }
        } catch (ex) {
          alert(ex.message);
        }
      }


So on the outsystems it does not find the asHost object, because the object needs to be placed on the screen in Outsystems, here is the part that I'm trying to figure out.
I have added the Saraff.axHost.cab  as a resource in Outsystems and I have set the target directory to '' , so it will place the object in the working directory of the page as stated in: (http://www.outsystems.com/help/servicestudio/9.0/Managing_Resources/About_Resources.htm)

It needs to install the activeX of the axhost to read the datasource I pressume.

How do I access the axhost object in the resources from the Javascript?

thanks in advance.