How to delete the particular page in tif file


#1

Hi,

        I want to delete the particular page in tif file. i use the below code to delete the page

for example i have tif with 19 pages i want to delete the 2nd page but it delete the 3rd page in tif file.

Dim oldfile As String = “D:\tif\CCITT_1.tif”

    Using image As TiffImage = DirectCast(Aspose.Imaging.Image.Load(oldfile), TiffImage)
        Dim frame As TiffFrame = Nothing

        image.RemoveFrame(2)
       
        image.Save("D:\tif\output.tif")
    End Using

Note:
** I want delete multiple page also that one also need**


#2

@senthilnathan,

Can you please share source file so that we may further investigate to help you out.


#3

hi,

         Thank for reply i send source file


#4

@senthilnathan,

I suggest you to please visit the following thread link for your kind reference.


#5

Hi,

  Thanks for reply in pdf and tif i  delete the multiple page.

for example:
Dim oldfile1 As String = “D:\tif1\doc1.pdf”
Dim oldfile As String = “D:\tif1\CCITT_1.tif”
Dim TeamIndex() As Integer = {1, 4}
for Pdf:

Dim pdfEditor As New PdfFileEditor()

                pdfEditor.Delete(oldfile1, TeamIndex,D:\tif\output1.pdf")

it delete the particular 1 and 4th pages

for tif:
Dim frameIndex As Integer = 0
Dim tiff As TiffImage = DirectCast(Aspose.Imaging.Image.Load(oldfile), TiffImage)

    If tiff.Frames.Length > 1 Then
        For i As Integer = 0 To TeamIndex.Count() - 1
            If frameIndex = 0 Then
                tiff.ActiveFrame = tiff.Frames(frameIndex + 1)
            End If

            tiff.RemoveFrame(frameIndex)
            'tiff.Save(retVal)
        Next
        tiff.Save("D:\tif\output.tif")
    End If

If i give 1 and 4th pages it delete first two pages this is not correct order.

Note:

Like pdf we want to delete particular page 1 and 4


#6

@senthilnathan,

I have observed the sample code shared by you and there seems to be no issue. I request you to please share the source file and generated output with us that I may investigate on my end to help you further.


#7

hi,

         Pls refer above already i send the source file.

image.png (7.2 KB)


#8

@senthilnathan,

I have worked with source file and sample code shared by you. I like to inform that pages is numbered from 0 not from 1. That is why you need delete pages 0 and 3.

Dim tiff As TiffImage = DirectCast(Aspose.Imaging.Image.Load(oldfile), TiffImage)

tiff.ActiveFrame = TiffImage.Frames(1)

Dim frame = TiffImage.RemoveFrame(3); ’ delete page 4
frame.Dispose()

frame = TiffImage.RemoveFrame(0); ’ delete page 1
frame.Dispose()

tiff.Save(“D:\tif\output.tif”)