I am currently working on a Java desktop application that interacts with a scanner. The concept is straightforward: the user should be able to open the application, select the scanner option, which will launch the scanner’s application. The user can then scan an image and click submit, at which point my application should receive the image and save it to the file system.
I have managed to get this functionality working using a TWAIN driver, but I’m encountering an issue with the scanner Im using (CZUR ET 16). This scanner allows for scanning multiple images before submitting them. Currently, when the user submits all the images, my application only processes the first one. How can I modify my application to process all scanned images upon submission?
I am using Java 8 32-bit and the library uk.co.mmscomputing.device.twain. Below is the code for the image submission:
public void update(ScannerIOMetadata.Type type, ScannerIOMetadata metadata) {
System.out.println("Funcion update ");
if (type.equals(ScannerIOMetadata.ACQUIRED)) {
System.out.println("1 ");
this.image = metadata.getImage();
this.jframe.ok1().setText("Documento escaneado satisfactoriamente "+metadata.getInfo());
this.scanner.removeListener(this);
}
else if (type.equals(ScannerIOMetadata.STATECHANGE)) {
System.out.println("2 ");
System.err.println(metadata.getStateStr());
if (metadata.isFinished());
}
else if (!type.equals(ScannerIOMetadata.NEGOTIATE) &&
type.equals(ScannerIOMetadata.EXCEPTION)) {
System.out.println("3 ");
this.jframe.error().setText("Error accediendo al dispostivo de escanner");
metadata.getException().printStackTrace();
}
}
The update function is currently capable of processing just one image. I am unsure whether the problem lies in my code or if the TWAIN driver is not sending all the images. Any help would be greatly appreciated.
To provide a clearer idea of how the application works, I am including a screenshot. This screenshot shows the interface of the scanner’s application (this is not the one I developed). Here, you can see all the scanned images and the submit button. Once the submit button is pressed, my application receives the image.
Thanks!