Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanning from ADF returning only first page #58

Open
jaidan22 opened this issue Mar 14, 2024 · 7 comments
Open

Scanning from ADF returning only first page #58

jaidan22 opened this issue Mar 14, 2024 · 7 comments

Comments

@jaidan22
Copy link

jaidan22 commented Mar 14, 2024

Hi @soukoku ,

I am currently using an HP LaserJet Pro printer with an ADF. While using the TWAIN driver, I issue encountered was - only the first page is returned to the application, even though all pages pass through the feeder. Interestingly, when I switch to the WIA Driver, everything works as expected, and all pages are returned.

The sample project are also showing the same behavior. However, when I tested an alternate package, it worked fine. Based on this, it seems less likely that the scanner itself is the problem.

Below are the capability values:

CapAutomaticSenseMedium = False 
CapPaperDetectable = True 
ICapFeederType = General 
CapFeederEnabled = True 
ICapPixelType / Depth = BlackWhite 
CapAutoFeed = True 
CapAutoScan = False 
CapAutoScan.CanSet = False 
CapXferCount = -1 
CapFeederLoaded = True 
CapFeedPage = False 
CapClearPage = False 
CapRewindPage = False 
@jaidan22
Copy link
Author

The following code snippet is from TransferLogic.cs file

// some poorly written scanner drivers return failures on EndXfer, so also check for the pending count now.
// this may break with other sources but we'll see
if (//pending.Count == 0 && 
    session.State > 5)
{
    session.ChangeState(5, true);
    session.DisableSource();
}

Why is pending.Count == 0 commented? Could this be the reason behind this error?

@fuchuba
Copy link

fuchuba commented Apr 9, 2024

Hi @jaidan22 , I encountered the same issue when using the HP scanjet 2000 scanner with ADF. I comment "//pending.Count == 0 &&" off, and test again. There is still only the first page returned to the application. May I ask if you have resolved it? If it's resolved, can you tell me how it was resolved?

@jaidan22
Copy link
Author

No. It hasn't been resolved yet.

@fuchuba
Copy link

fuchuba commented Apr 28, 2024

I edited the source code file that name "NTwain\Internals\TransferLogic.cs". I replaced the line “rc = session.DGControl.PendingXfers.Get(pending);” with code snippet below:

ReturnCode rc = ReturnCode.Failure;
if (session.CurrentSource.Identity.ProductName.IndexOf("scanjet", StringComparison.OrdinalIgnoreCase) > -1 || session.CurrentSource.Identity.ProductName.IndexOf("HP", StringComparison.OrdinalIgnoreCase) > -1)
{
    rc = ReturnCode.Success;
}
else
{
    rc = session.DGControl.PendingXfers.Get(pending);
}

I compiled on x86 architecture and tried again. The HP scanjet 2000 scanner seemed to work ok for ADF.
But I compiled on x64 architecture and tried again. The HP scanjet 2000 scanner seemed not to work good for ADF.
Advice to use on x86 architecture. Good luck!

@abhinavshrivastavabpk
Copy link

Hello,

I am also facing the same issue with HP Scan Jet Pro 2600 f1 ( Twain 2.4) and HP Pro M478f-9f TW (Twain 2.1).

I added debug statements inside Internals\TransferLogic.cs file in DoTransferRoutine() function and figured out that
rc = session.DGControl.PendingXfers.EndXfer(pending);
returns pending.count as 0 after first page is scanned even though there are more pages in the ADF.

When pending.count =0 , the below while statement fails and execution comes out of this while responsible for scanning multiple pages from ADF.
while (rc == ReturnCode.Success && pending.Count != 0 && !session.CloseDSRequested);

This means session.DGControl.PendingXfers.EndXfer(pending) is not returning the correct value of pending.

Any help will be highly appreciated.

Thanks.

@abhinavshrivastavabpk
Copy link

abhinavshrivastavabpk commented May 21, 2024

Hello,

I printed all capabilities.
Out of all capabilities in the list, "ICapPhysicalHeight: 122" and "ICapFrames: L=0, T=0, R=8.5, B=122" caught my attention.
The page length is coming as 122 inches.
According to HP user manual, 8.5 by 122 inches is an Extra Long Page Size, and, "Only one page can be scanned when using a long or extra long page setting". I think this is why I am not able to scan more than one page.

I changed the page length through SupportedSizes = USLetter.
I again printed the list of all capabilities.
Now "ICapPhysicalHeight: 122" and "ICapFrames: L=0, T=0, R=8.266663, B=11.67999".
But still I am not able to scan more than one page.

If "ICapPhysicalHeight: 122" restricting me from scanning more than one page, why is HP Twain driver sending Physical width as 122 ?

Any Suggestions.

Thanks

jaidan22 pushed a commit to jaidan22/ntwain that referenced this issue Sep 25, 2024
@JoshuaBurrows
Copy link

Hi all,

I seem to be running into similar issues to what has been described in previous comments on this thread, just figured I'd share what I've observed so far.

NOTE: I tested Jaidan22's "fix image scanning pending count #64 " pull request against the NTwain sample solutions and that resolves the below issues I'm seeing.

I've been running into issues with the HP ScanJet Pro 2000 s2 scanner which is exhibiting the following behaviour:

  1. On a single paged scan, the scan will run but no data will be transferred to the application.
  2. On a multi-paged scan all pages will be scanned but only the first page is transferred to the application.
  3. If enabling the source with UI, both single paged and multi paged scans work correctly (the UI dialog doesn't set any capabilities differently than case number one).
  4. The WIA source works correctly.

I've tried debugging (both in my application and in the NTwain sample projects) and the Visual Studio debugger abruptly dies after stepping past a call to Source.Open() (I've only seen this when using this HP TWAIN source). I've had to run logging against live instances of my application or detach the debugger in order to observe the above behaviour.

Any suggestions or advice on a way forward would be appreciated.

Thanks,

Josh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants