VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    JBIG2: How to remove page from JBIG2 document?
    In This Topic
    Page of JBIG2 document can 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