GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / IsPageImage Method / IsPageImage(Int32,Boolean) Method
Output parameter. If the currently selected page is an image-based page as defined above, this parameter returns a unique image identifier of the newly created GdPictureImage object corresponding to the embedded image. If the page is not image-based, this parameter returns 0.

Be aware that you need to release the successfully created image after being used, for the suitable method please refer to the Remarks section below.

Set this parameter to true if you want to automatically rotate the created image representing by the GdPictureImage object to get the same rendering orientation (for display or print) as is the viewing mode of the current page. Otherwise set it to false.

You can use the GdPicturePDF.GetPageRotation method to find out if the current page should be rotated when displayed or printed.

Example





In This Topic
IsPageImage(Int32,Boolean) Method
In This Topic
Returns if the currently selected page of the loaded PDF is entirely image-based. If yes, the method returns a unique image identifier referring to the newly created image object of the type GdPictureImage, that corresponds to the embedded image. You can take advantages of the GdPictureImaging class and its methods for further manipulation with the resulting image.

Image-based pages are considered to contain nothing but one fully visible image covering the whole page area. This image must not be in any way rotated and must not contain any other particular drawing operation such as a clipping path.

Syntax
'Declaration
 
Public Overloads Function IsPageImage( _
   ByRef ImageID As Integer, _
   ByVal AutoRotate As Boolean _
) As Boolean
public bool IsPageImage( 
   ref int ImageID,
   bool AutoRotate
)
public function IsPageImage( 
   var  ImageID: Integer;
    AutoRotate: Boolean
): Boolean; 
public function IsPageImage( 
   ImageID : int,
   AutoRotate : boolean
) : boolean;
public: bool IsPageImage( 
   ref int ImageID,
   bool AutoRotate
) 
public:
bool IsPageImage( 
   int% ImageID,
   bool AutoRotate
) 

Parameters

ImageID
Output parameter. If the currently selected page is an image-based page as defined above, this parameter returns a unique image identifier of the newly created GdPictureImage object corresponding to the embedded image. If the page is not image-based, this parameter returns 0.

Be aware that you need to release the successfully created image after being used, for the suitable method please refer to the Remarks section below.

AutoRotate
Set this parameter to true if you want to automatically rotate the created image representing by the GdPictureImage object to get the same rendering orientation (for display or print) as is the viewing mode of the current page. Otherwise set it to false.

You can use the GdPicturePDF.GetPageRotation method to find out if the current page should be rotated when displayed or printed.

Return Value

true if the currently selected page is entirely image-based as defined above, otherwise false. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Likewise just to remind you that you need to release the image, if it has been created successfully, after being used using either the GdPictureImaging.ReleaseGdPictureImage method or the static GdPictureDocumentUtilities.DisposeImage method.

Example
How to reuse an image from the image-based page in the PDF document. The image is subsequently drawn onto a new page and saved into a new PDF document.
Dim caption As String = "Example: IsPageImage"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("drawing.pdf", False)
If status = GdPictureStatus.OK Then
    status = gdpicturePDF.SelectPage(1)
    If status = GdPictureStatus.OK Then
        Dim imageID As Integer = 0
        Dim result As Boolean = gdpicturePDF.IsPageImage(imageID, True)
        status = gdpicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            If result Then
                Dim name As String = gdpicturePDF.AddImageFromGdPictureImage(imageID, False, True)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    If gdpicturePDF.SaveToFile("drawing_duplicated.pdf") = GdPictureStatus.OK Then
                        MessageBox.Show("The image has been successfully duplicated.", caption)
                    End If
                Else
                    MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption)
                End If
                GdPictureDocumentUtilities.DisposeImage(imageID)
            Else
                MessageBox.Show("This page is not image-based.", caption)
            End If
        Else
            MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption)
        End If
    Else
        MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: IsPageImage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("drawing.pdf", false);
if (status == GdPictureStatus.OK)
{
    status = gdpicturePDF.SelectPage(1);
    if (status == GdPictureStatus.OK)
    {
        int imageID = 0;
        bool result = gdpicturePDF.IsPageImage(ref imageID, true);
        status = gdpicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
        {
            if (result)
            {
                string name = gdpicturePDF.AddImageFromGdPictureImage(imageID, false, true);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    if (gdpicturePDF.SaveToFile("drawing_duplicated.pdf") == GdPictureStatus.OK)
                        MessageBox.Show("The image has been successfully duplicated.", caption);
                }
                else
                {
                    MessageBox.Show("The AddImageFromGdPictureImage() method has failed with the status: " + status.ToString(), caption);
                }
                GdPictureDocumentUtilities.DisposeImage(imageID);
            }
            else
                MessageBox.Show("This page is not image-based.", caption);
        }
        else
            MessageBox.Show("The IsPageImage() method has failed with the status: " + status.ToString(), caption);
    }
    else
        MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also