SimulPiscator / AirSane

Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
GNU General Public License v3.0
247 stars 26 forks source link

Support Duplex Scanning #56

Open ShadesJeff opened 3 years ago

ShadesJeff commented 3 years ago

When using the ADF on my scanner, even if airsaned sets the input source to ADF Duplex it does not load (buffer) the backside images and transfer them via the NextDocument request from the client application.

When doing duplex scanning with an ADF, I would expect airsaned to transfer 2 x [number of pages] images through multiple calls to NextDocument. The client application should then compile the files as appropriate into many single-page documents or into a single multi-page document depending on settings.

elsiehupp commented 3 years ago

I don’t know if there’s much I can add to the coding process in your fork, but I’d be happy to test any changes you make.

ShadesJeff commented 3 years ago

Hi @elsiehupp - if you could test the modifications on the devel branch, that would be awesome. If they work out, hopefully they can be integrated into the main project at some point. Thanks!

c-goes commented 3 years ago

I can scan two sides of a page into a PDF with scansnap using the web application. But in macOS there is no option to scan duplex as far as I can see.

SimulPiscator commented 3 years ago

In macOS, you only have the option to choose between flatbed and ADF. To scan multiple pages from the ADF, choose PDF as output format, and check "Scan into single document" below the output format drop-down menu.

c-goes commented 3 years ago

In macOS, you only have the option to choose between flatbed and ADF. To scan multiple pages from the ADF, choose PDF as output format, and check "Scan into single document" below the output format drop-down menu.

I tried this in macOS but it only scans one side of each paper.

ShadesJeff commented 3 years ago

The base AirSane code does not have the capability to buffer the back-side scan from a duplex scanner. My fork has some very rudimentary buffering capability and, at least for me with a ScanSnap ix500, works for duplex scanning and with hardware edge detection (page length detection) also available and working. If a few people test it with various hardware variations and it works, then I will submit a pull request.

elsiehupp commented 3 years ago

It seems like there are a lot of limitations inherent to Apple’s particular implementation of the draft PWG Network Scan Service specification. Like apparently what happened is that nobody except Apple and HP really bothered to try implementing it (as AirScan and eSCL, respectively), so there hasn’t been much initiative to iterate on it and fix its peculiar bugs and quirks.

My impression is that it would be possible to implement a fuller feature set by modernizing Mattias Ellert’s TWAIN SANE Interface for MacOS X, which translates SANE into TWAIN on the Mac end, rather than on the Linux end. The issue is that the existing binaries are 32-bit only, so they don’t run on more recent versions of macOS, and the existing codebase doesn’t compile as-is in the current version of Xcode.

(Incidentally, Epson seems to use something more like Ellert’s approach, with a proprietary API connecting their network scanners to a TWAIN driver on the client end. The main downside of this approach is that requiring third-party drivers means that hardware doesn’t “just work”, which was the impetus behind Apple’s AirPrint implementation of the IPP protocol. For USB printers Apple just preloads literally gigabytes’ worth of drivers onto macOS, but they haven’t seemed particularly inclined to do anything similar with scanners, beyond providing a native TWAIN API.)

Anyway...I copied all of the sources linked from Mattias Ellert’s website into a GitHub repository a while back, but I haven’t really done anything with it, yet, because native Mac development is still a bit beyond me at this point. Obviously feel free to poke around in his code, if you feel so inclined, and I hope it’s helpful that I put it all in a single GitHub repository (since it was only available as a collection of disconnected web downloads previously).

markosjal commented 2 years ago

I know that some Canon scanner drivers have the ability to delete blank pages with some settings. Maybe this is something the SANE driver lacks and you have discovered a good motivation for it?

for eSCL.... Duplex scanners MUST be identified in the ScannerCapabilities with <scan:AdfDuplexInputCaps> and in the Avahi/Bonjour announcement with duplex=T

Maybe first you should ensure that these parameters are properly passed from SANE to AirSane and advertised correctly on the network

OSX has no duplex/simplex setting that I have ever seen

in comparison..... I can scan on a Canon imageFormula 215 (duplex scanner which has no drives for OSX Catalina) to OSX Catalina by way of my Windows host (server) running Twain2AirScan , but the windows driver seems to do a good job at deleting the blank pages though even when I insert all single sided pages.

This is why I say that for some of these scanners eliminating blank pages seems to be a part of the driver, and a necessary part it seems.

SimulPiscator commented 10 months ago

I have modified AirSane to improve behavior with ADFs. Please give it a try.