Loading...

Win32error [7] on TiffAddToNativeMultipage function

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Win32error [7] on TiffAddToNativeMultipage function

Postby britnis » Wed Aug 19, 2009 8:04 am

Hi Loic,

I am working on gdpicture pro version 5.9.3.

I am facing issues with creating a duplicate copy of a multipage tiff image. I am using a code similar to the following:

Code: Select all
    If FileExist Then
        fs.CreateFolder (Environ("temp") & "\imgTemp")
        Set oGdScanNext = New GdpicturePro5.cImaging
        oGdScanNext.SetLicenseNumber (GDPROserial)
        oGdScanNext.CreateImageFromFile (Environ("temp") & "\" & "save_" & strAppID & "\" & strFileName & ".tif")
        lImageID = oGdScanNext.GetNativeImage
       
        If oGdScanNext.TiffIsMultiPage(lImageID) Then
                iPgCount = oGdScanNext.TiffGetPageCount(lImageID)
        Else
                iPgCount = 1
        End If

        For iPCount = 1 To iPgCount
         Call oGdScanNext.TiffSelectPage(lImageID, iPCount)
            If iPCount = 1 Then
                  lOgdImgId = oGdScanNext.TiffSaveAsNativeMultiPage(Environ("temp") & "\imgTemp\" & strFileName & ".tif", lCompression)
            Else
                  lOgdImgId = oGdScanNext.TiffAddToNativeMultipage(oGdScanNext.GetNativeImage)
            End If
        Next


All I am trying out is to create a dummy folder by the name imgTemp on the %temp% directory if a folder by the name save_XXX is found.
Then copy the files of the save_XXX to the imgTemp folder. Proceed with the scan operation and then merge the newly scanned image to the tiff image of the imgTemp folder.
Then save the resultant image to the save_XXX folder.

I could do this successfully for the first time that is if I have a single paged tiff image on the save_XXX folder. In case of a multipage tiff on the save_XXX folder, the operation fails.
I found a error number 7 [Win32error] on the line oGdScanNext.TiffAddToNativeMultipage(oGdScanNext.GetNativeImage). Please guide me through this issue.

Regards,
Nirmal Kumar L
britnis
 
Posts: 18
Joined: Tue Sep 02, 2008 12:47 pm

Re: Win32error [7] on TiffAddToNativeMultipage function

Postby Loïc » Thu Aug 20, 2009 9:17 am

Hi,

First I suggest you to use the latest edition available.

Also, you should replace this line:

Code: Select all
lOgdImgId = oGdScanNext.TiffSaveAsNativeMultiPage(Environ("temp") & "\imgTemp\" & strFileName & ".tif", lCompression)

By this one:

Code: Select all
lOgdImgId = oGdScanNext.TiffSaveAsNativeMultiPage(Environ("temp") & "\imgTemp\" & strFileName & "2.tif", lCompression)


Kind regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4437
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Re: Win32error [7] on TiffAddToNativeMultipage function

Postby britnis » Thu Aug 20, 2009 12:15 pm

Hi Loic,

Thanks for your response to the query that I posted. But, unfortunately the win32error persists for the change that you recommended.

Can you provide me with a code snippet for the following screnario:

usually if there is no folder by the name save_Application ID [This application id ll be provided through the parameter], then the scan process is performed with the creation of the folder save_XXX on the %temp% directory.

In case of further scanning using the same function, an additional folder imgTemp should be created on the %temp% directory and a copy of the image from the save_XXX should be saved to the imgTemp folder using the function Imaging.TiffSaveAsNativeMultipage() method.

Then the image obtained from the scan operation should be appended to the image on imgTemp folder using the function Imaging.TiffAddToNativeMultipage().

Later the files from the imgTemp folder will be moved to the save_XXX folder. For your information, my code works fine when save_XXX folder has a single paged tiff image. The issue is with the Multipage Tiff image on the save_XXX folder.

On moving the 2 page / Multipage Tiff image, the attempt to save the second page returns error number 7 / Win32error.

Please do the needful Loic.

Regards,
Nirmal Kumar L
britnis
 
Posts: 18
Joined: Tue Sep 02, 2008 12:47 pm

Re: Win32error [7] on TiffAddToNativeMultipage function

Postby britnis » Mon Sep 07, 2009 5:27 am

Hi Loic,

Can you provide me with a solution for this issue?

I have tried to create a clone using the latest available Gd Picture Pro 5.11.0.

A code similar to the below provided is used:

Code: Select all
    FileExist = fs.FileExists(Environ("temp") & "\" & "save_" & strAppID & "\" & strFileName & ".tif")
    If FileExist Then
        fs.CreateFolder (Environ("temp") & "\imgTemp")
       
       nlImageID = Imaging1.TiffCreateMultiPageFromFile(Environ("temp") & "\" & "save_" & strAppID & "\" & strFileName & ".tif")
       lOgdImgId = Imaging1.TiffSaveMultiPageToFile(nlImageID, Environ("temp") & "\imgTemp\" & strFileName & ".tif")
       nlImageID = Imaging1.TiffCreateMultiPageFromFile(Environ("temp") & "\imgTemp\" & strFileName & ".tif")
       
    End If
   
    While Imaging1.CreateImageFromTwain(UserControl.hWnd) <> 0
        lImageID = Imaging1.GetNativeImage
       
        If Imaging1.IsBlank(98) Then
            lOgdImgId = Imaging1.CloseImage(lImageID)
        Else
            lImageCount = lImageCount + 1
            If FileExist = False Then
                If lImageCount = 1 Then
                   lOgdImgId = Imaging1.TiffSaveAsNativeMultiPage(Environ("temp") & "\" & "save_" & strAppID & "\" & strFileName & ".tif", 4)
                Else
                   lOgdImgId = Imaging1.TiffAddToNativeMultipage(lImageID)
                   lOgdImgId = Imaging1.CloseImage(lImageID)
                End If
                If lOgdImgId <> 0 Then
                    Imaging1.TwainCloseSource
                    Imaging1.TwainCloseSourceManager (UserControl.hWnd)
                    Imaging1.TwainUnloadSourceManager
                    Err.Number = lOgdImgId
                    Call Gd_ErrorHandler(Err.Number)
                    ScanDocument = False
                    GoTo Error_Handler
                Else
                    ScanDocument = True
                End If
            Else
                 lOgdImgId = Imaging1.TiffSaveAsNativeMultiPage(Environ("temp") & "\imgTemp\" & strFileName & "_tmp.tif", 4)
                Imaging1.TiffCloseNativeMultiPage
                 lImageID = Imaging1.TiffCreateMultiPageFromFile(Environ("temp") & "\imgTemp\" & strFileName & "_tmp.tif")
               
                lOgdImgId = Imaging1.TiffInsertPageFromGdPictureImage(nlImageID, 2, lImageID)
               
                lOgdImgId = Imaging1.CloseImage(nlImageID)
                lOgdImgId = Imaging1.CloseImage(lImageID)
                Imaging1.TiffCloseNativeMultiPage
                If lOgdImgId <> 0 Then
                    Imaging1.TwainCloseSource
                    Imaging1.TwainCloseSourceManager (UserControl.hWnd)
                    Imaging1.TwainUnloadSourceManager
                    If fs.FolderExists(Environ("temp") & "\imgTemp") = True Then
                        fs.DeleteFolder (Environ("temp") & "\imgTemp")
                        Set fs = Nothing
                    End If
                    Err.Number = lOgdImgId
                    Call Gd_ErrorHandler(Err.Number)
                    ScanDocument = False
                    GoTo Error_Handler
                Else
                    ScanDocument = True
                End If
            End If
        End If
  Wend


The code
lOgdImgId = Imaging1.TiffInsertPageFromGdPictureImage(nlImageID, 2, lImageID)
do not create an expected mutipage image as it requires an Editable mutipage image for this process. But the image ID lImageID is found to be a non-editable one. Can there be an option to convert this non-editable image to an editable one?

Regards,
Nirmal Kumar L
britnis
 
Posts: 18
Joined: Tue Sep 02, 2008 12:47 pm


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 2 guests