Select twain source as a html drop down menu

Example requests & Code samples for GdPicture Toolkits.
Post Reply
miraca2014
Posts: 4
Joined: Mon Jun 02, 2014 5:32 pm

Select twain source as a html drop down menu

Post by miraca2014 » Wed Jul 16, 2014 5:43 pm

Hello,
I am new to gdPicture and I have a requirement to show the select twain source as a drop down menu in the html page. I use javascript to deal with all the gdPicture stuff. This menu should list all the sources that are available. For example, on my machine the html drop down menu should be like :
1. SPOT basic 5.1 standard (default selected)
2. SPOT advanced 5.1
3. Twain sample DS virtual scanner

I was able to select the default source as virtual scanner using -
m_GdPictureImaging.TwainOpenDefaultSource(0); it directly opens up the UI for virtual scanner and lets me upload the image.

The requirement also states that as soon as I change the selected option from the drop down to any other option it should the rekindle the function acquireTWAINAdf() and change the selected source to the one selected from the html drop down menu and show the UI for aquiring image from there.
Please help me out with a code sample.

SamiKharma
Posts: 352
Joined: Tue Sep 27, 2011 11:47 am

Re: Select twain source as a html drop down menu

Post by SamiKharma » Thu Jul 17, 2014 6:04 pm

Hi,

This is a high level app request, meaning it should not be included in the SDK. The SDK returns the available resources, the application should list then in which ever way the app developers deem reasonable.

Also, please do not duplicate the form multiple times, it just trashes the forum with the same request, making it hard for other users to navigate it.

Best,
Sami

miraca2014
Posts: 4
Joined: Mon Jun 02, 2014 5:32 pm

Re: Select twain source as a html drop down menu

Post by miraca2014 » Fri Jul 18, 2014 6:17 pm

Could you please suggest me a way to list the sources in my html page drop down.....or at-least how to get the list of available sources using javascript. I am just able to get the default source but not the list of all available sources.

Sorry for duplicating the form, wont happen again!
Thanking you in anticipation.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Select twain source as a html drop down menu

Post by Loïc » Fri Jul 18, 2014 6:38 pm

Hello,

Here a js to store all available source's name in an array:

Code: Select all

var oGdPictureImaging = new ActiveXObject("GdPicture10.GdPictureImaging");
var twainSources = new Array();
var sourceCount = oGdPictureImaging.TwainGetSourceCount(0);
for(i = 1; i <= sourceCount; i++)
{
   twainSources.push(oGdPictureImaging.TwainGetSourceName(0, i));
}
alert(twainSources);
Hope this helps!

With best regards,

Loïc

miraca2014
Posts: 4
Joined: Mon Jun 02, 2014 5:32 pm

Re: Select twain source as a html drop down menu

Post by miraca2014 » Fri Aug 01, 2014 11:48 pm

Thanks a ton, Loic ! You saved my day.
Now I am confused what to do in case they change the value in the source drop down.

I tried this:
On change event of that drop down I fired the whole InitGdPicture() and then function acquireTWAINAdf() .
Now inside the function acquireTWAINAdf() {
unlockGdPicture();
closeDocument;
var status;
var oGdViewer = document.getElementById("GdViewer1");
var aShell = new ActiveXObject('WScript.Shell');
var tempDir = aShell.ExpandEnvironmentStrings('%temp%');
m_GdPictureImaging.TwainLogStart("c:\\twainlog.txt"); //line to generate TWAIN LOG
m_GdPictureImaging.TwainSelectSource(?????????)

So here how should I select the "selected" source (from dropdown) inside TwainSelectSource method .

Please help me out.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest