tags:

views:

900

answers:

2

Is there a way to get an image from a usb scanner (on Windows primarily, cross-platform solution would be best) and post the image together to a form in browser with Flex or Java applet?

thx!

A: 

Well, to access a USB device from Flex or Java, you'd need a library / API that offers access to USB.

Unfortunately, neither Flex nor Java have an API that supports USB devices in their standard JDK.

There is a USB API for Java, developed under JSR 80:

http://javax-usb.org/

It is not ( yet?) part of the JDK, but it is standardized. Unfortunately, there are only implementations for Linux and BSD. You might be able to use that. See also http://stackoverflow.com/questions/444497/using-java-and-usb-which-api-jsr-80-jusb .

That said, you might want to consider other options. Maybe you can write a small wrapper program to do the scanning, and have the applet invoke that? Signed Java applets can invoke native software on the system.

Or just let people specify a directory to read images from (again possible if a Java applet is signed), then have people use the regular scanner software to scan to that directory. You could even poll the directory, so the applet picks up the image automatically...

sleske
+1  A: 

The standardized TWAIN scanning interface is definitely the place for you to look at, rather than low-level USB, except if you are targeting only one specific device and know how to talk to it.

Java based

There is another Stack Overflow question pointing out a link to a open Applet talking to a TWAIN device. If you're looking to spend no money, and build it yourself, that is maybe a starting point.

The only ready-made commercial product on the market that I can see is JTwain. I don't have any TWAIN devices handy to test, but it looks good.

TWAIN seems be on its way to Linux as well, and the makers of the commercial product promise support for other platforms in the future.

Active X / Plugin-based

There is at least one product connecting Twain on a Windows-only, ActiveX/Browser plugin basis, claiming to support all major browsers. A 30-day trial version is available.

Pekka