Cross Platform Scan Library

For a long time, it annoyed me that you need special software to create a multi-page PDF document from a flatbed scanner. Since β€œscanner” is an ambiguous word (which REALLY makes search difficult!), Let me explain: I mean, for example, the process by which the HP F4280 printer / scanner device optically β€œscans” a paper document and creates a digital presentation, it usually ends as aa.jpg or .tif file.

The problem is that I do not know which program is cross-platform and capable of creating multi-page scans from a flatbed scanner. To do this, the software must store each scanned page one at a time and ask the user if they want to scan another page. You cannot rely on a driver to handle multi-page scanning, because drivers only do this for feed channel scanners, which will β€œsuck” a stack of paper without pause and combine the data before transferring it to the driver frame.

Therefore, I begin the path to creating such a program. At a low level, I want to support TWAIN and SANE interfaces, on Windows XP or later, Mac OS X and popular Linux distributions 2.6 ok. 2008 or later.

This is how I assume it will work. First, I need a library that provides a single API, regardless of whether it uses TWAIN or SANE on the server. The API should be able to provide a byte array of bits, compressed, or other scanned data. You must open several properties that are shared between TWAIN and SANE: for example, DPI, paper size, and color / grayscale / lineart. Then it should be possible to either specify an explicit hint or request the resulting image format of an array of bytes, which is returned from a successful scan.

I am not interested in the programming environment: I am familiar with all the popular imperative / OO languages. I would prefer something like Java or C #, but C or C ++ worked just fine too.

Once I have such a library in hand, I can build a graphical interface that simply calls the routines as needed, and use one of several available PDF rendering libraries to create the output. I do not insist on "compile once, run anywhere", but I insist on "write once, compile anywhere", at least. Of course, since TWAIN and SANE are different APIs that are available on mutually exclusive platforms, at some point there must be some #ifdefs or other method of distinguishing between platforms to determine which API to use.

I intend to use my program and any libraries that I directly refer to to qualify as free software (for FSF), but the only requirement that I have in the programming environment is that it is available equivalently in Windows XP or later, Mac OS X and Linux 2.6.

I searched a lot to find such a library, but I can’t even find proprietary, not to mention free software. If someone found such a gem, please provide me a link - otherwise you will be given tips on getting started with my application. If necessary, I myself will create the aforementioned library and display it as a separate project under the GNU LGPL. For an application, I would prefer to write it in Qt4 / C ++, .NET with GTK # or Java / Swing, for maximum cross-platform compatibility.

+4
source share
2 answers

I know I'm 8 years late, but finally I can give you a library that seems to fit your requirements: Libinsane :-). It supports Sane, WIA2 and TWAIN. You will need MSYS2 to build it on Windows.

I wrote this for my personal project: Paperwork

+1
source

Unfortunately, TWAIN is a strictly limited standard. Most manufacturers implement only sufficient TWAIN functionality to run their own graphical interface. Trying to use the lower-level TWAIN functions and your own graphical interface is not a practical solution unless you are actually targeting a specific scanner.

+2
source

Source: https://habr.com/ru/post/1336499/


All Articles