Is it a must to scan multiple documents to a temporary file?

Discussions about image processing and document imaging.
Post Reply
mabdullah
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Is it a must to scan multiple documents to a temporary file?

Post by mabdullah » Mon Feb 07, 2011 11:36 am

I have an application which was written in VB6 code and I have almost 50 users using this application and one server.
The application is installed on the server and all users run the application through shortcut , so the problem is when the users scan multiple documents they will save it to the same temporary file, plz help

this snippet code to scan multiple documents and save it to a temp file (TIFF)

Code: Select all

Dim nImageCount As Integer
    Dim nImageID As Long
    CloseImage
    If Imaging1.TwainGetState < 4 Then Imaging1.TwainOpenDefaultSource
    If Imaging1.TwainOpenDefaultSource() Then
        nImageCount = 0
        Imaging1.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
        Imaging1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
        Imaging1.TwainSetCurrentResolution (200)
        Imaging1.TwainSetCurrentPixelType (TWPT_BW) 'BW black and white
        Imaging1.TwainSetCurrentBitDepth (1) ' 1 bpp
        Do
            nImageID = Imaging1.TwainAcquireToGdPictureImage(Me.hwnd)
            nImageCount = nImageCount + 1
            DisplayNativeImage
            If nImageCount = 1 Then
                Call Imaging1.TiffSaveAsNativeMultiPage(App.path & "\output.tif", CompressionCCITT4)
            Else
                Imaging1.TiffAddToNativeMultiPage (nImageID)
                Imaging1.CloseImage (nImageID)
            End If
        Loop While Imaging1.TwainGetState > TWAIN_SOURCE_OPEN
        Imaging1.TiffCloseNativeMultiPage
        Imaging1.TwainCloseSource
        Call Imaging1.TiffCreateMultiPageFromFile(App.path & "\output.tif")
        If Imaging1.GetStat = 0 Then
            Call ShowBitmap
            Call ShowBitmapProperties
            Call EnableDisableControls
        End If
        MsgBox "Done !"
    Else
        MsgBox "can't open default source, twain state is: " & Trim(Str(Imaging1.TwainGetState))
    End If
 

Tom Moran
Posts: 102
Joined: Thu May 24, 2007 9:41 am
Location: Phoenix, Arizona

Re: Is it a must to scan multiple documents to a temporary f

Post by Tom Moran » Mon Feb 07, 2011 6:08 pm

Hi Mabdullah:

There are a couple of ways you can do that. You probably will want to use the GetTempFilename API.

Go here for code snippet from Microsoft:

http://support.microsoft.com/kb/195763

Here is another way:

http://www.visualbasic.happycodings.com ... ode15.html

Tom

mabdullah
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: Is it a must to scan multiple documents to a temporary f

Post by mabdullah » Mon Feb 07, 2011 10:50 pm

thanks tom, but i didn't want to create a unique temp file, cause if i did i will create a many files on the server and eat my space, is there a way to scan multiple files directly to the gdviewer and not use temp file

Tom Moran
Posts: 102
Joined: Thu May 24, 2007 9:41 am
Location: Phoenix, Arizona

Re: Is it a must to scan multiple documents to a temporary f

Post by Tom Moran » Mon Feb 07, 2011 10:55 pm

I guess the question is what happens to the file after it's scanned? Does the user save it with a different file name?

In any event, you can delete the temp files after the user has completed their task. That will free up the disk space taken during the scan process.

Tom

mabdullah
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: Is it a must to scan multiple documents to a temporary f

Post by mabdullah » Tue Feb 08, 2011 7:10 am

Tom Moran wrote:I guess the question is what happens to the file after it's scanned? Does the user save it with a different file name?
Thanks tom for your fast response but i think my question is clear enough and i am asking if is it a must to scan multiple documents using ADF to a temporary file (TIF or PDF) then reload it to the gdviewer and not directly to gdviewer, anyway i will use your function to generate unique file name and i will delete this temp file after scanning.

mabdullah
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: Is it a must to scan multiple documents to a temporary f

Post by mabdullah » Tue Feb 08, 2011 8:15 am

ok i scanned the documents into multiple tif file and save it to hard disk and then reload it to the gdviewer but when trying to delete the file it gives me error at "DeleteFile function" "permission denied" and i think because i am trying to delete after reloading to gdviewer

Code: Select all

If Imaging1.TwainOpenDefaultSource() Then
        nImageCount = 0
        Imaging1.TwainSetAutoFeed (True) 'Set AutoFeed Enabled
        Imaging1.TwainSetAutoScan (True) 'To  achieve the maximum scanning rate
        Imaging1.TwainSetCurrentResolution (200)
        Imaging1.TwainSetCurrentPixelType (TWPT_BW) 'BW black and white
        Imaging1.TwainSetCurrentBitDepth (1) ' 1 bpp
        Do
            nImageID = Imaging1.TwainAcquireToGdPictureImage(Me.hwnd)
            nImageCount = nImageCount + 1
            DisplayNativeImage
            If nImageCount = 1 Then
                Call Imaging1.TiffSaveAsNativeMultiPage(strPath & "\" & TxtDoc_No & "_" & GetSetting("EzWay", "User", "User_Id", "") & ".tif", CompressionCCITT4)
            Else
                Imaging1.TiffAddToNativeMultiPage (nImageID)
                Imaging1.CloseImage (nImageID)
            End If
        Loop While Imaging1.TwainGetState > TWAIN_SOURCE_OPEN
        Imaging1.TiffCloseNativeMultiPage
        Imaging1.TwainCloseSource
        Call Imaging1.TiffCreateMultiPageFromFile(strPath & "\" & TxtDoc_No & "_" & GetSetting("EzWay", "User", "User_Id", "") & ".tif")
        If Imaging1.GetStat = 0 Then
            Call ShowBitmap
            Call ShowBitmapProperties
            Call EnableDisableControls
        End If
        Call DeleteFile(strPath & "\" & TxtDoc_No & "_" & GetSetting("EzWay", "User", "User_Id", "") & ".tif")
        MsgBox "Done !"


Tom Moran
Posts: 102
Joined: Thu May 24, 2007 9:41 am
Location: Phoenix, Arizona

Re: Is it a must to scan multiple documents to a temporary f

Post by Tom Moran » Tue Feb 08, 2011 4:22 pm

...error at "DeleteFile function" "permission denied" and i think because i am trying to delete after reloading to gdviewer
I believe you are correct, Mabdullah... you must first finish the document processing (saving with different file name, printing, etc.) before you can kill the temporary file.

mabdullah
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: Is it a must to scan multiple documents to a temporary f

Post by mabdullah » Tue Feb 08, 2011 6:12 pm

if you look to my previous code of scanning where i should put "DeleteFile" function

mabdullah
Posts: 18
Joined: Sun Jan 16, 2011 11:44 am

Re: Is it a must to scan multiple documents to a temporary f

Post by mabdullah » Sun Mar 06, 2011 11:49 am

hey Loïc any updates dude about this issue ??
mabdullah wrote:if you look to my previous code of scanning where i should put "DeleteFile" function

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest