none
How to scan image on a button click and save it in a location with user specified file name in vb net RRS feed

  • Question

  • Hi Team,

    How to scan image on a button click and save it in a location with user specified file name.

    Please need a clear explanation in vb .net not c#, or referel links
    Is there any way without using third party tool


    • Edited by SissyRam Monday, January 1, 2018 8:35 AM
    Monday, January 1, 2018 8:35 AM

Answers

  • https://social.msdn.microsoft.com/Forums/vstudio/en-US/518be8db-07b0-4713-b8aa-1075b28adda2/how-do-i-scan-with-wia-using-vbnet?forum=vbgeneral

    I think I got it

    • Marked as answer by SissyRam Monday, January 8, 2018 10:56 AM
    Monday, January 8, 2018 10:53 AM

All replies

  • Please make a clear explanation about what you want to do.
    What do you mean by "scan image"? Is it a feature like an image scanner does, or a feature of taking a screenshot?
    If it is screenshot, what range does a user take? full screen, some rectangle area???

    Ashidacchi

    Monday, January 1, 2018 9:07 AM
  • Thanks for the reply.

    I am preparing project for Human resource. I need scan employees documents as image or pdf and save it in a location(folder) with employee code. While creating report I need extract same image.

    If doesn't not have option to scan on button click then,

    Suggest me some options like choosing a image and re-naming it and save it in a location


    • Edited by SissyRam Monday, January 1, 2018 9:16 AM
    Monday, January 1, 2018 9:14 AM
  • Hi,

    Sorry, I still cannot have a clear understanding of your requirements.
    You wrote "scan employees documents". What is "document"? Is it a file which opened on computers, or physical paper?
    If it is a file, what extension does it have (e.g. .docx, txt, etc.)?
    If paper, do you have an image scanner? 

    Regards,

    Ashidacchi



    • Edited by Ashidacchi Monday, January 1, 2018 9:28 AM
    Monday, January 1, 2018 9:21 AM
  • Documents are physical papers such as aadhar card, driving license, address proof etc.,

    Yes we have scanner with us.

    Instead of scanning and then choosing file separately, I need to code in button click event to scan and save it with employee code or employee number.

    Files may scanned as image or pdf or both.

    Employee photo scanned as image, documents as pdf.

    While creating report I need get image (employee photo) with information.

    Kindly let me know for further doubts

    Monday, January 1, 2018 9:27 AM
  • It seems you want a complete program. Here we help with programming, so show what you have so far.


    Success Cor

    Monday, January 1, 2018 9:29 AM
  • Sorry if I incomplete.Only thing in need know can we scan image using scanner in vb .net or not.

    While surfing net it shows suggestion like use third party tool to scan images in vb .net

    See friends I have already created whole project report creation also I will do.

    Only need the code to scan image from scanner and save it in a location with user specified file name.

    • Edited by SissyRam Monday, January 1, 2018 9:38 AM
    Monday, January 1, 2018 9:36 AM
  • Hi SissyRam,

    I'm afraid you cannot do what you want in one action (by clicking a button). It would require some API provided by a manufacturer of your scanner.

    I suppose you want do like this:
    Pressing a button (on Windows Form) will make scanning to start and save a scanned image as a specific file format to a specific folder (already defined). That is manipulate the scanner like manually using some utility provided by the make.

    Regards,

    Ashidacchi

    Monday, January 1, 2018 9:38 AM
  • Hi again,

    I suppose you can do it with some user's manual action.

    1. By using a utility provided by the manufacturer, scan papers and save them in one folder: this is done manually (not by your software).

    2. By using an application you will make, select a scanned/saved file and associate it with an employee. This is fired by clicking a button. 
    Regards,

    Ashidacchi

    • Marked as answer by SissyRam Monday, January 1, 2018 9:50 AM
    • Unmarked as answer by SissyRam Monday, January 8, 2018 10:56 AM
    Monday, January 1, 2018 9:45 AM
  • Thanks for the suggestion.

    Correct me if I wrong.

    I can Scan the docs or image using API provided by a manufacturer only.

    I can open and save it using opendialog and savedialog right?

    I have misunderstood that vb .net have built in code to choose scanner and scan image.

    Monday, January 1, 2018 9:46 AM
  • I am new to vb .net.

    Anyway Thanks for the help brothers

    Monday, January 1, 2018 9:47 AM
  • How to scan image on a button click and save it in a location with user specified file name.

    On Windows 10, it can be done with GetImageDialog() from ScanSetting.dll (directory as 2nd parameter, file name as 3rd parameter )

    but I don't know for other OS (and it doesn't seem documented...)

    I tested and it displays this dialog (french) :

    • Marked as answer by SissyRam Monday, January 8, 2018 10:03 AM
    • Unmarked as answer by SissyRam Monday, January 8, 2018 10:56 AM
    Monday, January 1, 2018 12:32 PM
  • Hi Castorix31,

    SissyRam (also I) will be happy, if you explain how to scan an image from a paper via an image scanner (hardware device). I don't mean scan from an image file.

    Regards,

    Ashidacchi

    Monday, January 1, 2018 12:43 PM
  • The test I did on Windows 10 :

    Similar to IWiaDevMgr2::GetImageDlg but without all the Interfaces declarations

    'user must have rights on folder
    Dim wsFolder As String = "e:\foo"
    Dim wsFile As String = "image"
    Dim plNumFiles As IntPtr = IntPtr.Zero
    Dim p2 As IntPtr = IntPtr.Zero
    Dim pWiaItem21 As IntPtr = IntPtr.Zero
    Dim pWiaItem22 As IntPtr = IntPtr.Zero
    ' last parameter = 1 : scanner can be modified
    ' returns :
    ' S_OK = 0
    ' S_FALSE = 1 if cancel
    ' &H0021000B if modify scanner button
    Dim hr As Integer = GetImageDialog(Me.Handle, wsFolder, wsFile, plNumFiles, p2, pWiaItem21, pWiaItem22, 0)

    Declaration :

    <DllImport("ScanSetting.dll", CharSet:=CharSet.Unicode, SetLastError:=True)>
        Public Shared Function GetImageDialog(hWndParent As IntPtr, pwsFolder As String, pwsFilename As String, ByRef plNumFiles As IntPtr, ByRef p2 As IntPtr, ByRef pWiaItem21 As IntPtr, pWiaItem22 As IntPtr, nDisplay As Integer) As Integer
        End Function

    • Marked as answer by SissyRam Monday, January 8, 2018 10:03 AM
    • Unmarked as answer by SissyRam Monday, January 8, 2018 10:56 AM
    Monday, January 1, 2018 7:06 PM
  • Thanks friends this is what I need.

    I will test the code and let you give simplified solution.

    @Castorix31 can you tell me how to use this dialog "GetImageDialog()" in vb .net.

    See We can print the documents in vb right. There may be a code available to scan image  from scanner too.

    Third party tool is scanning the image.

    While printing os chooses default printer and print the documents right?

    Then Why cant image scanned from scanner?

    Monday, January 8, 2018 10:08 AM
  • Thanks for your valuable response @ Castorix31  wsFolder is this saving location?
    Monday, January 8, 2018 10:10 AM
  • Here is the code to print:

    https://www.experts-exchange.com/questions/28618021/how-to-print-a-jpg-file-using-vb-net-without-showing-the-print-dialog.html

    Same like looking for scanner to scan image

    Monday, January 8, 2018 10:12 AM
  •  wsFolder is this saving location?
    Yes, it is the same value as bstrFolderName of IWiaDevMgr2::GetImageDlg
    Monday, January 8, 2018 10:30 AM
  • https://social.msdn.microsoft.com/Forums/vstudio/en-US/518be8db-07b0-4713-b8aa-1075b28adda2/how-do-i-scan-with-wia-using-vbnet?forum=vbgeneral

    I think I got it

    • Marked as answer by SissyRam Monday, January 8, 2018 10:56 AM
    Monday, January 8, 2018 10:53 AM