JBIG2: How to remove page from JBIG2 document?
In This Topic
Page of JBIG2 document can be removed virtually, i.e. page will be marked as removed but page data will not be removed from file. Also page of JBIG2 document can be removed physically, i.e. page will be removed from catalog of JBIG2 document and all page data also will be removed.
Here is C#/VB.NET code that shows how to "virtually" remove page from JBIG2 document:
public void RemovePageFromJbig2FileVirtually(System.IO.Stream stream, int pageIndex)
{
// open JBIG2 file
using (Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File jbig2File =
new Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream))
{
// remove page at specified index
jbig2File.Pages.RemoveAt(pageIndex);
// save changes
jbig2File.SaveChanges();
}
}
Public Sub RemovePageFromJbig2FileVirtually(stream As System.IO.Stream, pageIndex As Integer)
' open JBIG2 file
Using jbig2File As New Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream)
' remove page at specified index
jbig2File.Pages.RemoveAt(pageIndex)
' save changes
jbig2File.SaveChanges()
End Using
End Sub
Here is C#/VB.NET code that shows how to "physically" remove page from JBIG2 document:
public void RemovePageFromJbig2FilePhysically(System.IO.Stream stream, int pageIndex,
System.IO.Stream outputStream)
{
// open JBIG2 file
using (Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File jbig2File =
new Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream))
{
// remove page at specified index
jbig2File.Pages.RemoveAt(pageIndex);
// save modified JBIG2 file to the outputStream,
// the source JBIG2 file is not changed
jbig2File.Pack(outputStream);
}
}
Public Sub RemovePageFromJbig2FilePhysically(stream As System.IO.Stream, pageIndex As Integer, outputStream As System.IO.Stream)
' open JBIG2 file
Using jbig2File As New Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(stream)
' remove page at specified index
jbig2File.Pages.RemoveAt(pageIndex)
' save modified JBIG2 file to the outputStream,
' the source JBIG2 file is not changed
jbig2File.Pack(outputStream)
End Using
End Sub