GdPicture.NET Reference Guide
TiffSwapPages Method (GdPictureImaging)
Example 





GdPicture14 Namespace > GdPictureImaging Class : TiffSwapPages Method
A unique image identifier of the GdPictureImage object representing the editable multipage TIFF image.
The page number of the one page you want to swap. It must be a value from 1 to TiffGetPageCount.
The page number of the other page you want to swap. It must be a value from 1 to TiffGetPageCount.
Swaps two pages specified by their page numbers in an editable multipage TIFF image, that is represented by its unique image identifier.

Please note that this method only handles editable multipage TIFF images; otherwise it will fail.

Syntax
'Declaration
 
Public Function TiffSwapPages( _
   ByVal ImageID As Integer, _
   ByVal Page1 As Integer, _
   ByVal Page2 As Integer _
) As GdPictureStatus
public GdPictureStatus TiffSwapPages( 
   int ImageID,
   int Page1,
   int Page2
)
public function TiffSwapPages( 
    ImageID: Integer;
    Page1: Integer;
    Page2: Integer
): GdPictureStatus; 
public function TiffSwapPages( 
   ImageID : int,
   Page1 : int,
   Page2 : int
) : GdPictureStatus;
public: GdPictureStatus TiffSwapPages( 
   int ImageID,
   int Page1,
   int Page2
) 
public:
GdPictureStatus TiffSwapPages( 
   int ImageID,
   int Page1,
   int Page2
) 

Parameters

ImageID
A unique image identifier of the GdPictureImage object representing the editable multipage TIFF image.
Page1
The page number of the one page you want to swap. It must be a value from 1 to TiffGetPageCount.
Page2
The page number of the other page you want to swap. It must be a value from 1 to TiffGetPageCount.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Be aware that this method only handles an editable multipage TIFF images. You can use the TiffIsEditableMultiPage method to check if a required image is an editable multipage TIFF image.

Likewise, for saving the provided modifications you need to use the TiffSaveMultiPageToFile(Int32,String,TiffCompression) method.

Example
How to swap a page in the specified multipage TIFF image.
Dim caption As String = "Example: TiffSwapPages"
Using oImage As GdPictureImaging = New GdPictureImaging()
    oImage.TiffOpenMultiPageForWrite(True)
    Dim imageID As Integer = oImage.TiffCreateMultiPageFromFile("multipage.tiff", True)
    If oImage.GetStat() = GdPictureStatus.OK Then
        If oImage.TiffIsEditableMultiPage(imageID) Then
            Dim compression As TiffCompression = oImage.GetTiffCompression(imageID)
            Dim pageCount As Integer = oImage.TiffGetPageCount(imageID)
            If oImage.GetStat() <> GdPictureStatus.OK Then GoTo Finished
        
            If oImage.TiffMovePage(imageID, 1, pageCount) <> GdPictureStatus.OK Then GoTo Finished
            If pageCount > 3 Then
                If oImage.TiffSwapPages(imageID, 2, 3) <> GdPictureStatus.OK Then GoTo Finished
            End If
            If oImage.TiffDeletePage(imageID, 1) <> GdPictureStatus.OK Then GoTo Finished
        
        Finished:
            If oImage.GetStat() = GdPictureStatus.OK Then
                If oImage.TiffSaveMultiPageToFile(imageID, "multipage.tiff", compression) = GdPictureStatus.OK Then
                    MessageBox.Show("Done!", caption)
                Else
                    MessageBox.Show("Error!    status: " + oImage.GetStat().ToString(), caption)
                End If
            Else
                MessageBox.Show("Error!    status: " + oImage.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("The specified image is not an editable multipage image.", caption)
        End If
        oImage.ReleaseGdPictureImage(imageID)
    Else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: TiffSwapPages";
using (GdPictureImaging oImage = new GdPictureImaging())
{
    oImage.TiffOpenMultiPageForWrite(true);
    int imageID = oImage.TiffCreateMultiPageFromFile("multipage.tiff", true);
    if (oImage.GetStat() == GdPictureStatus.OK)
    {
        if (oImage.TiffIsEditableMultiPage(imageID))
        {
            TiffCompression compression = oImage.GetTiffCompression(imageID);
            int pageCount = oImage.TiffGetPageCount(imageID);
            if (oImage.GetStat() != GdPictureStatus.OK) goto Finished;
 
            if (oImage.TiffMovePage(imageID, 1, pageCount) != GdPictureStatus.OK) goto Finished;
            if (pageCount>3)
                if (oImage.TiffSwapPages(imageID, 2, 3) != GdPictureStatus.OK) goto Finished;
            if (oImage.TiffDeletePage(imageID, 1) != GdPictureStatus.OK) goto Finished;
 
        Finished:
            if (oImage.GetStat() == GdPictureStatus.OK)
            {
                if (oImage.TiffSaveMultiPageToFile(imageID, "multipage.tiff", compression) == GdPictureStatus.OK)
                    MessageBox.Show("Done!", caption);
                else
                    MessageBox.Show("Error!    status: " + oImage.GetStat().ToString(), caption);
            }
            else
                MessageBox.Show("Error!    status: " + oImage.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("The specified image is not an editable multipage image.", caption);
        oImage.ReleaseGdPictureImage(imageID);
    }
    else
        MessageBox.Show("The image can't be created. Status: " + oImage.GetStat().ToString(), caption);
}
See Also

Reference

GdPictureImaging Class
GdPictureImaging Members
TiffIsEditableMultiPage Method
TiffOpenMultiPageForWrite Method
TiffCreateMultiPageFromFile(String) Method
TiffCreateMultiPageFromGdPictureImage Method
TiffSaveMultiPageToFile(Int32,String,TiffCompression) Method
TiffMovePage Method
TiffDeletePage Method