Going Paperless

Sign in to queue

The Discussion

  • User profile image
    Charlie Kindel

    Make this a Windows Home Server Add-In that is always available and automatically puts the scanned docs in the right place in a shared folder...

  • User profile image
    Sushant Bhatia

    Nice idea. As a future feature maybe someone can add support to then send these documents over to a Sharepoint Document Library (where metadata information can easily be searched on and the innards of scanned documents can be OCRed into Word documents or PDFs). Smiley

  • User profile image
    Clint

    @Eric:  Did you try to get it to work under Win2k?

  • User profile image
    Eric

    this is a cool program. Is that anyway I could run this program on Windows 2000?

  • User profile image
    Robert

    Hi,

    This is an example of just what I need, however, what must I do to get it to run on VISTA, I get an error that it can't find wiaLib?

  • User profile image
    Clint

    @Robert:  Email me, use the contact page at the top of the blog.

  • User profile image
    Robert

    OK, I have spent 2 days trying to get either of these examples to work in Vista, with the new 2008 express versions of C##, and VB. Is there anyone out there who can tell me what has to happen to make it work.

    Thank You

  • User profile image
    Rich

    The summary for the ScanDocument function says "Currently this is limited to single-image scans, but it is easy to modify." For the life of me, I can't figure out how to get this to batch scan multiple documents using a document feeder. Any ideas?

  • User profile image
    Ian Thomas

    Hi - good work!

    I came across your work when (web) searching for hints on using Windows Desktop Search to read the OLE Storage property pages (which are the "Properties" attached to Word and other documents).

    [ I haven't found a solution - which is why I'm posing the question to you ]

    I have used the DSOFile before (made sure of getting the latest version) with both Win32 and .NET, and for non-OLE Document files.

    I'm just surprised that Windows Desktop Search 4 (and probably 3.x) don't index the property sheets that some users fill in quite diligently. I suspect it is because Vista uses a different system for its file metadata (I'm not sure of this, though).

  • User profile image
    Almer

       Hi, first of all nice job.

       But, i am programming something very similar. I use WIA for scanning pictures from scanner, and

       WIA.Item lastItem = scannerDevice.ExecuteCommand( CommandID.wiaCommandTakePicture );

       throws and exception not implemented. can smbdy help me? i tried by

       scannerDevice.Items[this.m_ScannerIndex + 1].Transfer( imageFormat )

       but for first picture No problemo...but second callin this code returns me same pricture as before. What i did wrong?

  • User profile image
    Emmanuel Blanchette

    I have found a way to make this work for automatic document feeders.  Here is the code:

       Public Function ScanDocument()

           Dim hasMorePages As Boolean

           Dim docs As New List(Of Bitmap)()

           'Dim docs As Bitmap

           Dim currFilename As String

           ' Create a scanner instance (the user can select if more than one)

           Dim scanner As ItemClass = DirectCast(wiaManager.Create(missing), ItemClass)

           ' Show the standard scanning dialog (this is not a required step...)

           'Dim scans As CollectionClass = TryCast( _

           'scanner.GetItemsFromUI(WiaFlag.SingleImage, WiaIntent.ImageTypeText), _

           'CollectionClass)

           Dim scans As CollectionClass = TryCast(scanner.GetItemsFromUI(WiaFlag.SingleImage, WiaIntent.ImageTypeColor), CollectionClass)

           ' If the user clicks Cancel, collection is NULL

           If scans IsNot Nothing AndAlso scans.Count > 0 Then

               ' Transfer any scanned pictures to disk

               Dim scan As ItemClass

               For Each wiaObj As Object In scans

                   scan = DirectCast( _

                       Marshal.CreateWrapperOfType(wiaObj, GetType(ItemClass)), _

                       ItemClass)

                   ' create temporary file for image

                   currFilename = Path.GetTempFileName()

                   ' transfer picture to our temporary file

                   hasMorePages = True

                   Do While hasMorePages

                       scan.Transfer(currFilename, False) 'doit être exécuté pour chaque page!

                       'vérifier si le feeder est prêt pour une autre page!

                       hasMorePages = Convert.ToUInt32(scanner.GetPropById(WiaItemPropertyId.ScannerDeviceDocumentHandlingStatus))

                       'MessageBox.Show(hasMorePages)

                       ' Create a Bitmap from the loaded file (Image.FromFile locks the file...)

                       Using fs As New FileStream( _

                           currFilename, FileMode.Open, FileAccess.Read)

                           ' KLUDGE: Must wrap the FromStream Image with a new Bitmap.

                           ' Otherwise get OutOfMemoryException later when using ColorMatrix on it.

                           Dim myimage As New Bitmap(Image.FromStream(fs))

                           Dim MyThumbNail As Image

                           MyThumbNail = myimage.GetThumbnailImage(632, 825, AddressOf ThumbNailAbort, Nothing)

                           docs.Add(MyThumbNail)

                           fs.Close()

                       End Using

                       ' Don't leave junk behind!

                       File.Delete(currFilename)

                   Loop

               Next

           End If

           Return docs

       End Function

    The point of all this is to call the transfer method from the scanner for each page, verifying each time if a page is in the feeder.

  • User profile image
    antointhe

    Emmanuel, Arian

    I like the idea of what you're doing folks.  I had been thinking along the lines of creating a scanning app but I suppose 'stuff' got in the way Wink

    Does your code create a single output for the batch of scanned images or does it create mulltiples, Emmanuel?

    Please... do not reply in French or I'll have to spend a couple of months translating it!

  • User profile image
    JaK

    what about double sided scan? any clue?

  • User profile image
    Clint

    @JaK depends how the scanner works.  

    Coding4Fun attempts to show how to do some of the hard stuff but we can't cover every edge case such as this.

  • User profile image
    Alfredo

    I triying to do it with WIA 2.0 (not appear WiaLib) so, when i try to call at ShowSelectedDevice method appear a InvalidCastException Error.

    will leave the code here.

           public Form1()

           {

               InitializeComponent();

           }

           private void Form1_Load(object sender, EventArgs e)

           {

               Device dDevice = SelectDevice();

           }

           protected Device SelectDevice()

           {

               Device devScanner = null;

               CommonDialogClass cDialogScanner = new CommonDialogClass();

               devScanner = cDialogScanner.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, false, false);

               return devScanner;

           }

    and appear InvalidExceptionCast...

    I working with VS2008 in C# on VISTA

    my scanner HP ScanJet 3400C

    digitalports Angel gmail com

  • User profile image
    Clint

    @Alfredo ShowSelectDevice is returning a different typed object then.  It isn't returning a "Device" object

  • User profile image
    Cristian

    I am trying to save multiple scans (pages) in one TIFF file. I thought changing

    CollectionClass scans = scanner.GetItemsFromUI(WiaFlag.SingleImage, WiaIntent.ImageTypeText) as CollectionClass;

    into

    CollectionClass scans = scanner.GetItemsFromUI(WiaFlag.UseCommonUI, WiaIntent.MinimizeSize) as CollectionClass;

    will do it, but it didn't.

    I have one HP Scanjet G3010, on WinXP SP3, MS Visual Studio 2008. Using HP Solution Center (proprietary software) I am able to scan multiple pages in one TIFF file. I would really like to do it from your application.

    Your help/reply will be much appreciated. Thank you.

  • User profile image
    Cristian

    After some research, I will go with this method https://msdn.microsoft.com/en-us/library/ms630819(VS.85).aspx#FilterSharedSample015

    Anyway, if anybody has a better ideea, please let me know.

    Regards.

  • User profile image
    Cristian

    Sorry, I don't know how to edit the previous comment. I hope is obvious that I asked for a C# better ideea for my project. Thank you.

  • User profile image
    Clint

    @Cristian without relearning how this article works again, if your MSDN solution works, go with it.

  • User profile image
    cerinzano

    Hello, I want to make the capture whitout the line:

    CollectionClass scans = scanner.GetItemsFromUI(WiaFlag.SingleImage, WiaIntent.ImageTypeColor) as CollectionClass;

    I want to give the parametres, that It will be automatic

    but I do't know how.

    Any idea??

  • User profile image
    ArianKulp

    @cerinzano Sorry, this is a bit older and I never went back to update it.  A more recent example of WIA scanning in .NET that makes it easier to scan without the UI can be found here: 10rem.net/.../scanning-images-in-wpf-via-wia

Add Your 2 Cents