GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetPageImageColorSpace Method
The 0-based index of the image within the current page. It must be a value from 0 to GdPicturePDF.GetPageImageCount-1.
Example





GetPageImageColorSpace Method (GdPicturePDF)
Returns the color space of an image, specified by its index within the currently selected page of the loaded PDF document.
Syntax
'Declaration
 
Public Function GetPageImageColorSpace( _
   ByVal ImageIdx As Integer _
) As PdfColorSpace
 

Parameters

ImageIdx
The 0-based index of the image within the current page. It must be a value from 0 to GdPicturePDF.GetPageImageCount-1.

Return Value

A member of the PdfColorSpace enumeration. A color space of a specified image.

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.

Example
How to find out the colorspace of all images contained within the PDF document.
Dim caption As String = "Example: GetPageImageColorSpace"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim message As String = ""
    Dim imageCount As Integer = 0
    Dim colorspace As PdfColorSpace = PdfColorSpace.PdfColorSpaceUnknown
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If (status = GdPictureStatus.OK) AndAlso (pageCount > 0) Then
        For i As Integer = 1 To pageCount
            If gdpicturePDF.SelectPage(i) = GdPictureStatus.OK Then
                message = message + "Page nr." + i.ToString() + ":" + vbCrLf
                imageCount = gdpicturePDF.GetPageImageCount()
                status = gdpicturePDF.GetStat()
                If (status = GdPictureStatus.OK) AndAlso (imageCount > 0) Then
                    For j As Integer = 0 To imageCount - 1
                        colorspace = gdpicturePDF.GetPageImageColorSpace(j)
                        status = gdpicturePDF.GetStat()
                        If status = GdPictureStatus.OK Then
                            message = message + "The image indexed as " + j.ToString() + " has the following color space: " + colorspace.ToString() + "." + vbCrLf
                        Else
                            message = message + "The GetPageImageColorSpace() method has failed for the image nr. " + j.ToString() + " with the status: " + status.ToString() + vbCrLf
                        End If
                    Next
                Else
                    If status = GdPictureStatus.OK Then
                        message = message + "This page doesn't contain any image." + vbCrLf
                    Else
                        message = message + "The GetPageImageCount() method has failed for the page nr. " + i.ToString() + " with the status: " + status.ToString() + vbCrLf
                    End If
                End If
            Else
                message = message + "The SelectPage() method has failed for the image nr. " + i.ToString() + " with the status: " + gdpicturePDF.GetStat().ToString() + vbCrLf
            End If
        Next
        MessageBox.Show(message, caption)
    Else
        If status = GdPictureStatus.OK Then
            MessageBox.Show("This file doesn't contain any page.", caption)
        Else
            MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
        End If
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
See Also