VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    JBIG2: How to merge JBIG2 documents?
    In This Topic
    Here is C#/VB.NET code that shows how to merge several JBIG2 documents into one:
    public void MergeJbig2Files(System.IO.Stream firstStream, System.IO.Stream secondStream)
    {
        // open the first JBIG2 file
        using (Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File firstJbig2File = 
            new Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(firstStream))
        {
            // open the second JBIG2 file
            using (Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File secondJbig2File = 
                new Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(secondStream))
            {
                // for each page in the second JBIG2 file
                for (int i = 0; i < secondJbig2File.Pages.Count; i++)
                {
                    // add page of the second JBIG2 file to the first JBIG2 file
                    firstJbig2File.Pages.Add(secondJbig2File.Pages[i]);
                }
                // save changes to the first TIFF file
                firstJbig2File.SaveChanges();
            }
        }
    }
    
    Public Sub MergeJbig2Files(firstStream As System.IO.Stream, secondStream As System.IO.Stream)
        ' open the first JBIG2 file
        Using firstJbig2File As New Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(firstStream)
            ' open the second JBIG2 file
            Using secondJbig2File As New Vintasoft.Imaging.Codecs.ImageFiles.Jbig2.Jbig2File(secondStream)
                ' for each page in the second JBIG2 file
                For i As Integer = 0 To secondJbig2File.Pages.Count - 1
                    ' add page of the second JBIG2 file to the first JBIG2 file
                    firstJbig2File.Pages.Add(secondJbig2File.Pages(i))
                Next
                ' save changes to the first TIFF file
                firstJbig2File.SaveChanges()
            End Using
        End Using
    End Sub