Reference Guide
GdPicture14.WPF Namespace / GdViewer Class / GetPageThumbnail Method
The required width of the newly created thumbnail image, in pixels.
The required height of the newly created thumbnail image, in pixels.
The required page of the displayed document for creating the thumbnail.
A color object that defines the background color of the thumbnail's margins. The created thumbnail image includes predefined margin on both sides painted with the specified color.
Example





In This Topic
    GetPageThumbnail Method (GdViewer)
    In This Topic
    Creates a custom sized high quality (HQ) thumbnail of the specified page of the document displayed in the GdViewer control. The required page is converted to an image resource with the size and the background color you have specified, which is subsequently stored as an object of the type GdPictureImage. The created image is clearly recognizable by the returned unique image identifier and you can take advantages of the GdPicture14.GdPictureImaging or the GdViewer classes and their methods for further manipulation with the thumbnail.
    Syntax
    'Declaration
     
    
    Public Function GetPageThumbnail( _
       ByVal Width As Integer, _
       ByVal Height As Integer, _
       ByVal Page As Integer, _
       ByVal BackColor As Color _
    ) As Integer
    public int GetPageThumbnail( 
       int Width,
       int Height,
       int Page,
       Color BackColor
    )
    public function GetPageThumbnail( 
        Width: Integer;
        Height: Integer;
        Page: Integer;
        BackColor: Color
    ): Integer; 
    public function GetPageThumbnail( 
       Width : int,
       Height : int,
       Page : int,
       BackColor : Color
    ) : int;
    public: int GetPageThumbnail( 
       int Width,
       int Height,
       int Page,
       Color BackColor
    ) 
    public:
    int GetPageThumbnail( 
       int Width,
       int Height,
       int Page,
       Color BackColor
    ) 

    Parameters

    Width
    The required width of the newly created thumbnail image, in pixels.
    Height
    The required height of the newly created thumbnail image, in pixels.
    Page
    The required page of the displayed document for creating the thumbnail.
    BackColor
    A color object that defines the background color of the thumbnail's margins. The created thumbnail image includes predefined margin on both sides painted with the specified color.

    Return Value

    A unique image identifier of the GdPictureImage object representing the newly created thumbnail's image resource. The returned value is non-zero if the image is successfully created. Please first of all use the GetStat method to determine if this method has been successful.

    Just to remind you that you need to release the image using the ReleaseGdPictureImage method after being used.

    Remarks
    We strongly recommend using the GetStat method to identify the specific reason for the method's failure instead of checking the returned value.

    Likewise just to remind you that you need to release the image using the ReleaseGdPictureImage method.

    Example
    How to save the current page of the displayed document as a thumbnail in the PNG format.
    'We assume that the GdViewer1 control has been properly integrated.
    If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
        Dim imageID As Integer = GdViewer1.GetPageThumbnail(256, 256, GdViewer1.CurrentPage, Color.FromArgb(255, 180, 180, 180))
        If GdViewer1.GetStat() = GdPictureStatus.OK Then
            Using oGdPictureImaging As GdPictureImaging = New GdPictureImaging()
                If oGdPictureImaging.SaveAsPNG(imageID, "thumbnail.png") = GdPictureStatus.OK Then
                    MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail")
                Else
                    MessageBox.Show("The created thumbnail can't be saved. Status: " + oGdPictureImaging.GetStat().ToString(), "GdViewer.GetPageThumbnail")
                End If
            End Using
            GdViewer1.ReleaseGdPictureImage(imageID)
        Else
            MessageBox.Show("The thumbnail can't be created. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail")
        End If
    Else
        MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail")
    End If
    //We assume that the GdViewer1 control has been properly integrated.
    if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
    {
        int imageID = GdViewer1.GetPageThumbnail(256, 256, GdViewer1.CurrentPage, Color.FromArgb(255, 180, 180, 180));
        if (GdViewer1.GetStat() == GdPictureStatus.OK)
        {
            using (GdPictureImaging oGdPictureImaging = new GdPictureImaging())
            {
                if (oGdPictureImaging.SaveAsPNG(imageID, "thumbnail.png") == GdPictureStatus.OK)
                    MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail");
                else
                    MessageBox.Show("The created thumbnail can't be saved. Status: " + oGdPictureImaging.GetStat().ToString(), "GdViewer.GetPageThumbnail");
            }
            GdViewer1.ReleaseGdPictureImage(imageID);
        }
        else
            MessageBox.Show("The thumbnail can't be created. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail");
    }
    else
        MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.GetPageThumbnail");
    See Also