ImGearDocumentPageArray Class
Represents a collection of pages within
ImGearDocument object.
The following example illustrates how to change the order of pages in the document. This way of page array reordering is useful only for
ImGearRasterPage because such pages do not support the
System.IDisposable interface. For disposable pages like ImGearPDFPage removing pages from an array calls the Dispose() method, and any further page additions to this array will cause
System.ObjectDisposedException. To avoid the addition of a disposed page, it should be cloned before pulling it out from the array, and the clone should be inserted in the required position.
int pageCount;
ImGearDocument igDocument;
using (FileStream localFile = new FileStream(localFilePath, FileMode.Open))
{
pageCount = ImGearFileFormats.GetPageCount(localFile, ImGearFormats.UNKNOWN);
igDocument = ImGearFileFormats.LoadDocument(localFile, 0, pageCount);
}
//Check pages swap possibility
if (pageCount > 1)
{
ImGearPage igPage = igDocument.Pages[0];
igDocument.Pages.Remove(igPage);
igDocument.Pages.Insert(1, igPage);
}
Dim pageCount As Integer
Dim igDocument As ImGearDocument
Dim localFile As FileStream = New FileStream(localFilePath, FileMode.Open)
Try
pageCount = ImGearFileFormats.GetPageCount(localFile, ImGearFormats.UNKNOWN)
igDocument = ImGearFileFormats.LoadDocument(localFile, 0, pageCount)
Finally
localFile.Close()
End Try
'Check pages swap possibility
If (pageCount > 1) Then
Dim igPage As ImGearPage = igDocument.Pages(0)
igDocument.Pages.Remove(igPage)
igDocument.Pages.Insert(1, igPage)
End If