ImageControls 3.1 Application NoteImageControls Toolkit 3.1 is the latest release of the Kofax ImageControls Toolkit product. |
To access the following Web pages for this release, please click on the desired page's link. Application Notes - Error Codes - Frequently Asked Questions - Revision Levels - Supported Configurations |
Deleting Pages From a Multipage TIFFImageControls 3 allows you to insert and append pages to a multipage TIFF files. However, what is missing is the ability to delete individual pages from a multipage TIFF file. While a specific method is not provided for this purpose, the ability is still there. This article will address this particular issue.
There is only one form in the project. I have used control arrays whenever possible to simplify the code. Since you will be scanning from disk, you will need to make sure that you have a File Import Source selected as the default in the Kofax Source Manager (KSM). This can be either the default Software File Import Source or a Hardware File Import From Disk Source.
After Adding and sizing the Kview control, go to the Properties window and set the FitHeight and FitWidth properties to true so that you will be able to see the entire image. I also set the BandingMode property to Mouse Up Auto-Zoom and BandingModeRight to Pan. The larger SSCommand buttons are in a separate array from the two containing the arrow pictures. Following is the entire code listing for the project. All reserving and resetting is done in the Form_Load event. Files are opened using a CommonDialog control. The returned filename is then assigned to the global string g_FileName. Once the file is loaded the user can peruse the individual pages using the two arrow buttons. When a page is to be deleted, the Delete button is pressed and a Kscan Action Start (KSACTIONSTART) is initialized in batch mode and the IOWriteMode to Append. If however, no file has yet been loaded then a message box will be presented telling the user this. If the current displayed file only has one page then the user will be given a choice whether to delete the file. There are two separate counters used in the batch process: g_PECounter g_PSCounter These are nessesary to compensate for pre-scan cache (DeviceCache property) settings of greater than 0. The g_PSCounter is used to set the PSPage property of the input file being scanned. The g_PECounter is used to keep track of the current page being written out to disk. When the g_PECounter equals the current displayed page (Kview1.Page), the PEFileName property is set to "" thereby causing that page to not be written. This effectively deletes the page. In the Batch_End event, the old file is backed up the temporary file is copied to the current filename and the temporary file is deleted. In the Batch_End event, the old file is backed up the temporary
file is copied to the current filename and the temporary file
is deleted.
Case 1
'*** First check if an image has been loaded,
'*** then check whether the image only has one
'*** page and delete it if the user wishes else,
'*** start the scan from disk operation.
If KView1.filename = "" Then
MsgBox "A file has not yet been loaded"
ElseIf KView1.MultiPageCount = 1 Then
Status = MsgBox("This file has only one page._
Do you want to delete it?", vbYesNo)
If Status = vbYes Then
Kill g_FileName
KView1.filename = ""
KView1.Clear
End If
Else
With Kscan1
.IOWriteMode = KGIOWRITEMODEAPPEND
.DeviceMethod = KSDEVICEMETHODBATCH
.Action = KSACTIONSTART
End With
End If
Case 2 Kscan1.Action = KSACTIONUNRESERVE End End Select End Sub Private Sub SSCommand2_Click(Index As Integer) '*** Move through the pages With KView1 Select Case Index Case 0 If .Page > 1 Then .Page = .Page - 1 .Refresh Label1(1).Caption = "Current Page:" & Str$(.Page) End If Case 1 If .Page < .MultiPageCount Then .Page = .Page + 1 .Refresh Label1(1).Caption = "Current Page:" &_ Str$(KView1.Page) End If End Select End With End Sub |
