GetPageThumbnailAsBitmap Method
In This Topic
Creates a custom sized high quality (HQ) thumbnail of the specified page of the document displayed in the GdViewer control as a bitmap.
The required page is converted to an image thumbnail that fits within a rectangle of the size and the background color you have specified.
Syntax
'Declaration
Public Function GetPageThumbnailAsBitmap( _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Color _
) As Bitmap
public Bitmap GetPageThumbnailAsBitmap(
int ,
int ,
int ,
Color
)
public function GetPageThumbnailAsBitmap(
: Integer;
: Integer;
: Integer;
: Color
): Bitmap;
public function GetPageThumbnailAsBitmap(
: int,
: int,
: int,
: Color
) : Bitmap;
public: Bitmap* GetPageThumbnailAsBitmap(
int ,
int ,
int ,
Color
)
public:
Bitmap^ GetPageThumbnailAsBitmap(
int ,
int ,
int ,
Color
)
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
The newly created thumbnail's image as a bitmap. Please first of all use the
GetStat method to determine if this method has been successful.
Example
How to save the current page of the displayed document as a thumbnail in the PNG format using a bitmap.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim thumbnail As Bitmap = GdViewer1.GetPageThumbnailAsBitmap(256, 256, GdViewer1.CurrentPage, GdViewer1.ARGB(255, 180, 180, 180))
If GdViewer1.GetStat() = GdPictureStatus.OK Then
thumbnail.Save("thumbnail.png")
MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail")
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)
{
Bitmap thumbnail = GdViewer1.GetPageThumbnailAsBitmap(256, 256, GdViewer1.CurrentPage, GdViewer1.ARGB(255, 180, 180, 180));
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
thumbnail.Save("thumbnail.png");
MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail");
}
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");
Example
How to save the current page of the displayed document as a thumbnail in the PNG format using a bitmap.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
Dim thumbnail As Bitmap = GdViewer1.GetPageThumbnailAsBitmap(256, 256, GdViewer1.CurrentPage, GdViewer1.ARGB(255, 180, 180, 180))
If GdViewer1.GetStat() = GdPictureStatus.OK Then
thumbnail.Save("thumbnail.png")
MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail")
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)
{
Bitmap thumbnail = GdViewer1.GetPageThumbnailAsBitmap(256, 256, GdViewer1.CurrentPage, GdViewer1.ARGB(255, 180, 180, 180));
if (GdViewer1.GetStat() == GdPictureStatus.OK)
{
thumbnail.Save("thumbnail.png");
MessageBox.Show("The created thumbnail has been saved successfully.", "GdViewer.GetPageThumbnail");
}
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