Convert a multipage TIFF to a multipage JBIG2 in C#
This example shows how to convert a multipage TIFF file to a multipage JBIG2 file.
//We assume that GdPicture has been correctly installed and unlocked.string tifffilepath = "multipage.tif";string jb2filepath = "multipage.jb2";using (GdPictureImaging oGdPictureImaging = new GdPictureImaging()){ int TiffID = oGdPictureImaging.CreateGdPictureImageFromFile(tifffilepath); if (oGdPictureImaging.GetStat() == GdPictureStatus.OK) { int Jbig2ID = 0; int pageCount = oGdPictureImaging.TiffGetPageCount(TiffID); for (int i = 1; i <= pageCount; i++) { if (i == 1) { Jbig2ID = oGdPictureImaging.CreateClonedGdPictureImage(TiffID); if ((oGdPictureImaging.GetStat() != GdPictureStatus.OK) || (oGdPictureImaging.JBIG2SaveAsMultiPageFile(Jbig2ID, jb2filepath) != GdPictureStatus.OK)) { MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "TIFF to JBIG2 Example", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } else { if ((oGdPictureImaging.TiffSelectPage(TiffID, i) != GdPictureStatus.OK) || (oGdPictureImaging.JBIG2AddToMultiPageFile(Jbig2ID, TiffID) != GdPictureStatus.OK)) { MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "TIFF to JBIG2 Example", MessageBoxButtons.OK, MessageBoxIcon.Error); break; } } } if (oGdPictureImaging.GetStat() == GdPictureStatus.OK) MessageBox.Show("Done!", "TIFF to JBIG2 Example", MessageBoxButtons.OK, MessageBoxIcon.Information); oGdPictureImaging.JBIG2CloseMultiPageFile(Jbig2ID); oGdPictureImaging.ReleaseGdPictureImage(Jbig2ID); oGdPictureImaging.ReleaseGdPictureImage(TiffID); } else MessageBox.Show("Error: " + oGdPictureImaging.GetStat().ToString(), "TIFF to JBIG2 Example", MessageBoxButtons.OK, MessageBoxIcon.Error);}
This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.