带 Flex / Java 小程序的 USB 扫描仪?
有没有办法从 USB 扫描仪获取图像(主要在 Windows 上,跨平台解决方案最好)并使用 Flex 或 Java 小程序将图像一起发布到浏览器中的表单中?
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准化的 TWAIN 扫描接口绝对是您值得关注的地方,而不是低级 USB,除非您只针对一种特定设备并且知道如何与其通信。
基于Java
还有另一个Stack Overflow问题 指出与 TWAIN 设备对话的打开 Applet 的链接。如果您不想花钱并自己构建它,这可能是一个起点。
我能看到的市场上唯一现成的商业产品是 JTwain< /strong>。我没有任何方便测试的 TWAIN 设备,但它看起来不错。
TWAIN 似乎正在路上 也支持 Linux,并且商业产品的制造商承诺将来支持其他平台。
Active X / 基于插件
至少有一个产品 在仅限 Windows、ActiveX/浏览器插件的基础上连接 Twain,声称支持所有主要浏览器。提供 30 天试用版。
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.
那么,要从 Flex 或 Java 访问 USB 设备,您需要一个提供 USB 访问的库/API。
不幸的是,Flex 和 Java 的标准 JDK 中都没有支持 USB 设备的 API。
有一个用于 Java 的 USB API,在 JSR 80 下开发:
http://javax-usb.org/
它(还不是?) JDK 的一部分,但它是标准化的。不幸的是,只有 Linux 和 BSD 的实现。你也许可以用它。另请参阅使用 java 和 usb:哪个 api? jsr-80,jusb,...?。
也就是说,您可能需要考虑其他选择。也许您可以编写一个小型包装程序来进行扫描,然后让小程序调用它?签名的 Java 小程序可以调用系统上的本机软件。
或者只是让人们指定一个目录来读取图像(如果 Java 小程序已签名,这也是可能的),然后让人们使用常规扫描仪软件扫描到该目录。您甚至可以轮询目录,以便小程序自动拾取图像......
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 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...