Scanning Invoices (TWAIN?)

KlaasFeenstraKlaasFeenstra Member Posts: 35
Hello,

I am looking for a solution to activate a scanner from Microsoft Dynamics Nav using automation. I was looking on the internet for some freeware programs that I could use and with the use of automation, scan a document and once scanned, move it to another configured location. I hope someone can help me.

Thanks in advance,

Klaas

Comments

  • PeterDPeterD Member Posts: 66
    I don't know any freeware for that but recently had someone over of ScannerVision. That looked promising. Lot's of possibilities and it isn't expensive. But we only talked it through, were not using it ourselves.

    http://www.scannervision.eu/
  • MalajloMalajlo Member Posts: 294
    I tested it long time ago...
    Some globals are not necessary (I've tested filters and converting between different formats). But you can find out what to do.
    Name	DataType	Subtype	Length
    DeviceManager	Automation	'Microsoft Windows Image Acquisition Library v2.0'.DeviceManager	
    DeviceInfos	Automation	'Microsoft Windows Image Acquisition Library v2.0'.DeviceInfos	
    Device	Automation	'Microsoft Windows Image Acquisition Library v2.0'.Device	
    CommonDialog	Automation	'Microsoft Windows Image Acquisition Library v2.0'.CommonDialog	
    Item	Automation	'Microsoft Windows Image Acquisition Library v2.0'.IItem	
    Items	Automation	'Microsoft Windows Image Acquisition Library v2.0'.IItems	
    Property	Automation	'Microsoft Windows Image Acquisition Library v2.0'.Property	
    Properties	Automation	'Microsoft Windows Image Acquisition Library v2.0'.Properties	
    ImageFile	Automation	'Microsoft Windows Image Acquisition Library v2.0'.ImageFile	
    VT_Index	Variant		
    VT_Value	Variant		
    RlshpMgtCommentLine	Record	Rlshp. Mgt. Comment Line	
    CompanyInfo	Record	Company Information	
    SalesComment	Record	Sales Comment Line	
    FileOnly	Text		150
    i	Integer		
    FileName	Text		50
    
    Scan(FileNameIn : Text[50];"No." : Code[20];Scan_Date : Date;Tip : Text[30];NoPages : Integer)
    CompanyInfo.GET ;
    i:= 0 ;
    
    CREATE(DeviceManager) ;
    CREATE(CommonDialog) ;
    DeviceInfos := DeviceManager.DeviceInfos ;                     //Get WIA devices
    IF DeviceInfos.Count = 0 THEN EXIT ;                           //Check number of WIA devices
    Device := CommonDialog.ShowSelectDevice ;                      //If found at least 1 device, show WIA.SelectDeviceDialog
    Items := Device.Items ;                                        //Retrieve Items in device
    Item := Items.Item(1) ;                                        //... and we assume only one scanner (item(1)  )
    Properties := Item.Properties ;                                //enumerating Properties we can find DeviceType
    VT_Index := 5 ;  //HOR_RES                                     //Selecting specific property
    Property := Properties.Item(VT_Index) ;
    VT_Value := 150 ;
    Property.Value := VT_Value ;
    VT_Index := 6 ;  //VERT_RES
    Property := Properties.Item(VT_Index) ;
    VT_Value := 150 ;
    Property.Value := VT_Value ;
    VT_Index := 15 ; //Current Intent
    Property := Properties.Item(VT_Index) ;
    VT_Value := 4 ;
    Property.Value := VT_Value ;
    
    //Scan!!!
    REPEAT
    i := i + 1 ;
    FileName := FileNameIn+'-'+FORMAT(i)+'.bmp' ;
    CLEAR(ImageFile) ;
    CREATE(ImageFile) ;
    //MESSAGE(FileName) ;
    //IF NoPages > 1 THEN CommonDialog.ShowAcquireImage ;
    
    CommonDialog.ShowTransfer(Item) ;
    ImageFile := Item.Transfer ;
    
    //We should define filename
    IF EXISTS(CompanyInfo."Path for scanned documents"+'\'+FileName) THEN
     ERASE(CompanyInfo."Path for scanned documents"+'\'+FileName) ;
    ImageFile.SaveFile(CompanyInfo."Path for scanned documents"+'\'+FileName) ;
    
  • KlaasFeenstraKlaasFeenstra Member Posts: 35
    Thanks a lot for your post. It was of great value!!
  • KlaasFeenstraKlaasFeenstra Member Posts: 35
    I am testing the code for scanning invoices, but it only scans a part of the invoice. I am trying to find out wich property I have to set, but without any result. I hope someone can help me...
    Scan('Test',1)
    
    Scan(FileNameIn : Text[50];NoPages : Integer)
    CompanyInfo.GET ;
    i:= 0 ;
    
    CREATE(DeviceManager) ;
    CREATE(CommonDialog) ;
    DeviceInfos := DeviceManager.DeviceInfos ;                     //Get WIA devices
    IF DeviceInfos.Count = 0 THEN EXIT ;                           //Check number of WIA devices
    Device := CommonDialog.ShowSelectDevice ;                      //If found at least 1 device, show WIA.SelectDeviceDialog
    Items := Device.Items ;                                        //Retrieve Items in device
    Item := Items.Item(1) ;                                        //... and we assume only one scanner (item(1)  )
    Properties := Item.Properties ;                                //enumerating Properties we can find DeviceType
    VT_Index := 6 ;  //HOR_RES                                     //Selecting specific property
    Property := Properties.Item(VT_Index) ;
    VT_Value :=0  ;
    Property.Value := VT_Value ;
    {VT_Index := 6 ;  //VERT_RES
    Property := Properties.Item(VT_Index) ;
    VT_Value := 150 ;
    //Property.Value := VT_Value ;
    VT_Index := 15 ; //Current Intent
    Property := Properties.Item(VT_Index) ;
    VT_Value := 4 ;
    //Property.Value := VT_Value ;
    }
    //Scan!!!
    REPEAT
       i := i + 1 ;
       FileName := FileNameIn+'-'+FORMAT(i)+'.jpg' ;
       CLEAR(ImageFile) ;
       CREATE(ImageFile) ;
    //MESSAGE(FileName) ;
    CommonDialog.ShowAcquireImage(1,1,131072,wiaFormatJPEG) ;
    
    
    ImageFile := CommonDialog.ShowTransfer(Item,wiaFormatJPEG,TRUE) ;
    //ImageFile := Item.showTransfer(wiaFormatJPEG) ;
    
    //We should define filename
    IF EXISTS(CompanyInfo."Path for scanned documents"+'\'+FileName) THEN
    ERASE(CompanyInfo."Path for scanned documents"+'\'+FileName) ;
    ImageFile.SaveFile(CompanyInfo."Path for scanned documents"+'\'+FileName) ;
    UNTIL i = NoPages;
    
    Thanks
  • David_SingletonDavid_Singleton Member Posts: 5,479
    ...I was looking on the internet for some freeware programs that I could use ....


    Arrrrgghhhhhh ](*,) ](*,) ](*,) ](*,)

    Freeware has its place and I am a strong supporter of community based software. But it has its place and I am not saying you wont find a free product to do what you want. But you should be looking at the cost of the whole project, not the raw cost of the software, If you do that you will end out spending far more money than if you just bought a working product.

    Of course if you find a great freeware product, use it, But don't limit or even begin your search with the criteria of FREE.
    David Singleton
  • MalajloMalajlo Member Posts: 294
    I am testing the code for scanning invoices, but it only scans a part of the invoice. I am trying to find out wich property I have to set, but without any result. I hope someone can help me...
    Scan('Test',1)
    
    Scan(FileNameIn : Text[50];NoPages : Integer)
    CompanyInfo.GET ;
    i:= 0 ;
    
    CREATE(DeviceManager) ;
    CREATE(CommonDialog) ;
    DeviceInfos := DeviceManager.DeviceInfos ;                     //Get WIA devices
    IF DeviceInfos.Count = 0 THEN EXIT ;                           //Check number of WIA devices
    Device := CommonDialog.ShowSelectDevice ;                      //If found at least 1 device, show WIA.SelectDeviceDialog
    Items := Device.Items ;                                        //Retrieve Items in device
    Item := Items.Item(1) ;                                        //... and we assume only one scanner (item(1)  )
    Properties := Item.Properties ;                                //enumerating Properties we can find DeviceType
    VT_Index := 6 ;  //HOR_RES                                     //Selecting specific property
    Property := Properties.Item(VT_Index) ;
    VT_Value :=0  ;
    Property.Value := VT_Value ;
    {VT_Index := 6 ;  //VERT_RES
    Property := Properties.Item(VT_Index) ;
    VT_Value := 150 ;
    //Property.Value := VT_Value ;
    VT_Index := 15 ; //Current Intent
    Property := Properties.Item(VT_Index) ;
    VT_Value := 4 ;
    //Property.Value := VT_Value ;
    }
    //Scan!!!
    REPEAT
       i := i + 1 ;
       FileName := FileNameIn+'-'+FORMAT(i)+'.jpg' ;
       CLEAR(ImageFile) ;
       CREATE(ImageFile) ;
    //MESSAGE(FileName) ;
    CommonDialog.ShowAcquireImage(1,1,131072,wiaFormatJPEG) ;
    
    
    ImageFile := CommonDialog.ShowTransfer(Item,wiaFormatJPEG,TRUE) ;
    //ImageFile := Item.showTransfer(wiaFormatJPEG) ;
    
    //We should define filename
    IF EXISTS(CompanyInfo."Path for scanned documents"+'\'+FileName) THEN
    ERASE(CompanyInfo."Path for scanned documents"+'\'+FileName) ;
    ImageFile.SaveFile(CompanyInfo."Path for scanned documents"+'\'+FileName) ;
    UNTIL i = NoPages;
    
    Thanks
    Problem is your selection of scanned area, not the code. Can you scan full document from i.e. Word, PhotoShop?
  • KlaasFeenstraKlaasFeenstra Member Posts: 35
    When I select a preview, I see all of the page, but once scanned it only takes the bottem left of the page. When I use the scanner with other aplications, it works fine. Can you also give me a hint how to scan multiple pages in only one document?

    Thanks in advance!!!

    Klaas
  • MalajloMalajlo Member Posts: 294
    As I remember, it is possible to open Scan/preview dialog where you can change settings.

    I tried scanning multipage tiff but could not figure out how to. But that was 5 years ago and I had very few experience with automations.
    Now I'm using barcdes on documents and then, using barcode OCR and file splitter, split multipage tiff in separated pdf files.

    Search for WIA on Microsoft MSDN. I think you have to define format and other options.
  • mikelilinmikelilin Member Posts: 1
    first you need scan your invoice file using Twain, and save the scanned image to your computer, and then you need some free ocr software to recognize the text from the scanned image and document.
Sign In or Register to comment.