I am having trouble getting multiple pages to scan. My custom code and the sample code for WIA exhibit the same behavior. Below is the code in question (All pages -> Multipage TIFF).
Code: Select all
private void Command1_Click(System.Object eventSender, System.EventArgs eventArgs)
{
int nImageCount = 0;
int ImageID = 0;
int MultiPageID = 0;
if (OpenSelectedSource())
{
nImageCount = 0;
if (chkHideUI.CheckState == CheckState.Unchecked)
{
oGdPictureImaging.WiaShowSetupDialogSource();
}
oGdPictureImaging.WiaSelectFeeder(true);
do
{
ImageID = oGdPictureImaging.WiaAcquireToGdPictureImage();
if (ImageID != 0)
{
nImageCount = nImageCount + 1;
ApplyImageFilters(ImageID);
if (chkPreview.CheckState == CheckState.Checked)
{
DisplayImage(ImageID);
}
if (nImageCount == 1)
{
MultiPageID = ImageID;
oGdPictureImaging.TiffSaveAsMultiPageFile(MultiPageID, @"multipage.tif", TiffCompression.TiffCompressionCCITT4);
}
else
{
oGdPictureImaging.TiffAddToMultiPageFile(MultiPageID, ImageID);
oGdPictureImaging.ReleaseGdPictureImage(ImageID);
}
}
}
while (oGdPictureImaging.WiaGetLastError() == WiaStatus.WIA_OK);
oGdPictureImaging.TiffCloseMultiPageFile(MultiPageID);
MessageBox.Show("Done. WIA status: " + oGdPictureImaging.WiaGetLastError().ToString());
oGdPictureImaging.WiaCloseSource();
}
If 1 page is in the feeder, the program executes as expected with no issue with or without Duplex. If 2 pages are in the feeder, it scans the first page and then the second but hangs after. I can't break into the loop or detect any error. After killing the application, I have to unplug the scanner to get it to reset. This issue occurs with or with Duplex. I do get the same behavior using the PDF option in the sample. I have tried to change the loop to detect if the feeder has any pages, but as others have noted, that always returns true.
I saw there is a page dedicated to troubleshooting TWAIN issues, but I didn't see one for WIA. Does such a troubleshooting guide exist? Regardless, any help or tips would be appreciated.
Matthew
P.S. The scanner that I am testing with is a Fujitsu fi-8170 with current drivers.