ImageGear .NET v24.14 - Updated
ImGearDocumentPageArray Class
Members  Example 

ImageGear24.Core Assembly > ImageGear.Core Namespace : ImGearDocumentPageArray Class
Represents a collection of pages within ImGearDocument object.
Object Model
ImGearDocumentPageArray ClassImGearPage Class
Public Class ImGearDocumentPageArray 
Dim instance As ImGearDocumentPageArray
public class ImGearDocumentPageArray 
public __gc class ImGearDocumentPageArray 
public ref class ImGearDocumentPageArray 
On adding pages, checks that the new page is not attached to any other document. The Remove method detaches a page from the document. If it is referenced from anywhere else, it remains a valid stand-alone page.

The content of the array can only include the pages that correspond with the type of the document. For example, if the page array is a part of ImGearPDFDocument the type of pages should be ImGearPDFPage. The addition of any pages that do not correspond with the document type will cause an exception.

Well-formed page array may contain any number of null entries. An exception is made for the formats where pages are physically continuous (i.e., PDF). Note that setting a page to null is different from removing a page from the document - the former does not change page count, whereas the latter does.

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.Insert(1, igPage);
Dim pageCount As Integer
Dim igDocument As ImGearDocument
Dim localFile As FileStream = New FileStream(localFilePath, FileMode.Open)
    pageCount = ImGearFileFormats.GetPageCount(localFile, ImGearFormats.UNKNOWN)
    igDocument = ImGearFileFormats.LoadDocument(localFile, 0, pageCount)
End Try

'Check pages swap possibility
If (pageCount > 1) Then
    Dim igPage As ImGearPage = igDocument.Pages(0)
    igDocument.Pages.Insert(1, igPage)
End If
Inheritance Hierarchy


See Also


ImGearDocumentPageArray Members
ImageGear.Core Namespace