Montana Burr wrote:I want to build a Java app that can use any document scanner, whether it is connected to the same network as the computer or to the computer itself.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Montana Burr wrote:I want to build a Java app that can use any document scanner, whether it is connected to the same network as the computer or to the computer itself.
Well, from what I understand, TWAIN is a Windows standard, and this article suggests that there are ways of doing it; but it is nearly 10 years old. This one, which is quite a bit newer, suggests that JTwain or Morena might do what you want, but my thought is: why do you need to do this in Java?
There might well be a good reason, but scanners generally work pretty automatically, so why not just use Java to process the resulting file?
Winston
Montana Burr wrote:The Java app is to make it easier for someone who has an account on FamilySearch.org to scan a photo and upload it to the FamilySearch system. I want the app to know where the scanned image is without asking the user. Ideally, the user would tell the scanner to save the image to a location that is accessible to the computer, and the app would assume that the user wants to upload that image to FamilySearch. The app would allow the user to edit the image before the app uploads it. The app should allow the user to use his or her favorite image editing program, then, after the user saves the file, ask him or her if he or she is ready to upload it.
For the last part, I'm thinking of creating a loop in which the app checks the "Last Modified" date once per second. If it changes, that means the user will have edited the image.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Montana Burr wrote:The Java app is to make it easier for someone who has an account on FamilySearch.org to scan a photo and upload it to the FamilySearch system. I want the app to know where the scanned image is without asking the user. Ideally, the user would tell the scanner to save the image to a location that is accessible to the computer, and the app would assume that the user wants to upload that image to FamilySearch. The app would allow the user to edit the image before the app uploads it. The app should allow the user to use his or her favorite image editing program, then, after the user saves the file, ask him or her if he or she is ready to upload it.
OK, well it sounds to me like you have at least 3 different things going on here - Scanning, Editing, and Uploading - all three of which can probably be done by existing utilities. The last one could certainly be done directly with Java, the first two probably not (or at least not easily); so all your Java app is really doing is "tying them together".
So my first piece of advice would be to deal with them (at least initially) as 3 completely separate problems, and your post was about TWAIN libraries, so I'd stick with that part to kick off with. Get the document from the scanner to some file at a predetermined place in the system. You can then deal with Steps 2 and 3 later on.
I'm no expert on this but, given Java's cross-platform nature, I'd suspect that any "scanning library" you find written in Java is likely to be a compromise that does things in generic or "default" ways, and may well not support all the things that your scanner can actually do. I suspect also that the learning curve for such a library is pretty steep.
It also strikes me that an awful lot of this can probably be configured into your existing scanner software. Yes, it means a bit more set-up for the client, but it would probably only need to be done once, after which you could then just write/use your Java app as a launcher.
For the last part, I'm thinking of creating a loop in which the app checks the "Last Modified" date once per second. If it changes, that means the user will have edited the image.
Sounds overly complex to me. First (and it's purely a personal preference): I dislike passive "checkers" - ie, modules that simply sit and "buzz" until something happens. It seems far more sensible to me to have modules (or Java objects) notify each other when something has happened.
In your case - and sticking purely to the "scanning" part of your problem - I'd probably do something like this:
1. Configure your scanner software to save its images to a specific directory; and if you can configure a specific "Scan for Upload" button to do this, all the better. I have a cheap Canon one, and it allows me to do just that. Alternatively, configure your Java launcher to use the scanner software's own directory.
You might also want to force the scanner to always store documents as images (eg, jpegs) initially, so that your app doesn't have to deal with multiple formats. If left to its own devices, my scanner will choose what it thinks is the best file type for the task (PDFs for text or jpegs for images).
2. Configure your Java launcher to "know" where the scanner software is. Personally, I'd just use a properties file that it reads.
3. Write a Java program that simply launches the scanner software, and checks whether anything has been added to the target directory when it returns.
I suspect that while you're trying this out and getting it to work, other things may occur to you as to how to "streamline" the process, but for now stick purely to this part of the problem. Make sure that you can launch your scanner software and know what file (or files) it created when it returns. Every time.
HIH
Winston
Montana Burr wrote:1) I don't really care how the first two problems are solved...
2) I would like to eliminate as much work on the user's end as possible.
3) There is some sort of a file-system-watching API that might do the trick.
4) Ideally, the app would not rely on the presence of any scanning software that the scanner uses to scan anything to the computer. In my case, I can't tell the scanner to scan to my computer because somebody decided not to make my scanner's software compatible with OS X 10.9.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here