VintaSoft Imaging .NET SDK v8.8 for .NET Framework
In This Topic
    TIFF: How to remove page from TIFF file?
    In This Topic

    Page of TIFF file can be removed:



    Here is an example that shows how to "virtually" remove page from TIFF file:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    
    Public Sub VirtuallyRemovePageFromTiffFile(stream As System.IO.Stream, pageIndex As Integer)
            ' open TIFF file
            Using tiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream)
                    ' remove page at specified index
                    tiff.Pages.RemoveAt(pageIndex)
    
                    ' save changes
                    tiff.SaveChanges()
            End Using
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    
    public void VirtuallyRemovePageFromTiffFile(System.IO.Stream stream, int pageIndex)
    {
        // open TIFF file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiff = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream))
        {
            // remove page at specified index
            tiff.Pages.RemoveAt(pageIndex);
    
            // save changes
            tiff.SaveChanges();
        }
    }
                    
    


    Here is an example that shows how to "physically" remove page from TIFF file:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    
    Public Sub PhysicallyRemovePageFromTiffFile(stream As System.IO.Stream, pageIndex As Integer, outputStream As System.IO.Stream)
            ' open TIFF file
            Using tiff As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream)
                    ' remove page at specified index
                    tiff.Pages.RemoveAt(pageIndex)
    
                    ' save modified TIFF file to the outputStream,
                    ' the source TIFF file is not changed
                    tiff.Pack(outputStream)
            End Using
    End Sub
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    
    public void PhysicallyRemovePageFromTiffFile(
        System.IO.Stream stream, int pageIndex, System.IO.Stream outputStream)
    {
        // open TIFF file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiff = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(stream))
        {
            // remove page at specified index
            tiff.Pages.RemoveAt(pageIndex);
    
            // save modified TIFF file to the outputStream,
            // the source TIFF file is not changed
            tiff.Pack(outputStream);
        }
    }