GetPageThumbnail Method (GdViewer)
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.
public int GetPageThumbnail(
int ,
int ,
int ,
Color
)
public function GetPageThumbnail(
: Integer;
: Integer;
: Integer;
: Color
): Integer;
public function GetPageThumbnail(
: int,
: int,
: int,
: Color
) : int;
public: int GetPageThumbnail(
int ,
int ,
int ,
Color
)
public:
int GetPageThumbnail(
int ,
int ,
int ,
Color
)
'Declaration
Public Function GetPageThumbnail( _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Color _
) As Integer
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.
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");