VintaSoft Imaging .NET SDK and Plug-ins Discussions

Questions, comments and suggestions concerning VintaSoft Imaging .NET SDK.

Board index < VintaSoft Imaging < VintaSoft Imaging .NET SDK and Plug-ins Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

delete selected pages in sourcefile



delete selected pages in sourcefile

Post by gunnuy »

Hi,
I'd like to enable the user to have thumbnail viewer selected pages being deleted in the source file.
My approach ends here:
Dim selectedImage As VintasoftImage() = Nothing
Dim selectedIndices As Integer() = .thumbnailViewer1.SelectedIndices.ToArray()
If _myCollection.Count > 0 Then
    selectedImage = New VintasoftImage(selectedIndices.Length - 1) {}
    For i As Integer = 0 To _myCollection.Count - 1
        selectedImage(i) = .thumbnailViewer1.Images(_myCollection(i))
        Dim image As VintasoftImage = selectedImage(i)
        image.Dispose() ' problem is here
    Next
End If

How do I write back those remaining pages to the source file?
A code sample would greatly be appreciated!

Thank you and Best
Regards
Guenther


Re: delete selected pages in sourcefile

Post by Alex »

Hi Guenter,

Here is example that shows how to delete selected thumbnails in thumbnail viewer and save image in thumbnail viewer to a file. As filename can be used the name of new file or source file.
Private Sub RemoveSelecedImagesAndSave(thumbnailViewer As ThumbnailViewer, filename As String)
    Dim indexes As Integer() = thumbnailViewer.SelectedIndices.ToArray()
    Dim removingImages As New List(Of VintasoftImage)
    For Each index As Integer In indexes
        removingImages.Add(thumbnailViewer.Images(index))
    Next
    thumbnailViewer.Images.RemoveRange(indexes)
    
    For Each image As VintasoftImage In removingImages
        image.Dispose()
    Next
    
    Dim encoder As EncoderBase = AvailableEncoders.CreateEncoder(filename)
    encoder.SaveAndSwitchSource = True
    thumbnailViewer.Images.SaveSync(filename, encoder)
End Sub
Best regards, Alexander


Re: delete selected pages in sourcefile

Post by gunnuy »

Hallo Alex,

works as intended, thanks a lot!!


Page 1 from 1: 1