TIFF: How to remove page from TIFF file?
In This Topic
Page of TIFF file can be removed:
- virtually - page removed from catalog of TIFF file, page data is not removed i.e. size of TIFF file is not changed
- physically - page removed from catalog of TIFF file, page data removed i.e. size of TIFF file is decreased
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);
}
}