GdPicture.NET.14
GdPicture14 Namespace / GdPictureDocumentUtilities Class / GetDocumentPreview Method / GetDocumentPreview(String,Int32,Int32,Int32,DocumentFormat,Int32,Int32) Method
The full file path of the specified document.
The required width of the generated thumbnail of the first page, in pixels.
The required height of the generated thumbnail of the first page, in pixels.
The required background color of the generated thumbnail, in ARGB format.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The unique image identifier of a newly generated thumbnail image of the first page of the specified document. Be aware that you need to subsequently release this image from memory using the DisposeImage method after you have used it.
Output parameter. The total number of pages of the specified document.
Example





In This Topic
GetDocumentPreview(String,Int32,Int32,Int32,DocumentFormat,Int32,Int32) Method
In This Topic
Retrieves the format of a required document specified by its file path, the total number of pages of that document and produces the thumbnail of its first page according to the specified parameters.
Syntax
'Declaration
 
Public Overloads Shared Function GetDocumentPreview( _
   ByVal FilePath As String, _
   ByVal ThumbnailWidth As Integer, _
   ByVal ThumbnailHeight As Integer, _
   ByVal BackColor As Integer, _
   ByRef DocumentFormat As DocumentFormat, _
   ByRef ThumbnailID As Integer, _
   ByRef PageCount As Integer _
) As GdPictureStatus
public static GdPictureStatus GetDocumentPreview( 
   string FilePath,
   int ThumbnailWidth,
   int ThumbnailHeight,
   int BackColor,
   ref DocumentFormat DocumentFormat,
   ref int ThumbnailID,
   ref int PageCount
)
public function GetDocumentPreview( 
    FilePath: String;
    ThumbnailWidth: Integer;
    ThumbnailHeight: Integer;
    BackColor: Integer;
   var  DocumentFormat: DocumentFormat;
   var  ThumbnailID: Integer;
   var  PageCount: Integer
): GdPictureStatus; static; 
public static function GetDocumentPreview( 
   FilePath : String,
   ThumbnailWidth : int,
   ThumbnailHeight : int,
   BackColor : int,
   DocumentFormat : DocumentFormat,
   ThumbnailID : int,
   PageCount : int
) : GdPictureStatus;
public: static GdPictureStatus GetDocumentPreview( 
   string* FilePath,
   int ThumbnailWidth,
   int ThumbnailHeight,
   int BackColor,
   ref DocumentFormat DocumentFormat,
   ref int ThumbnailID,
   ref int PageCount
) 
public:
static GdPictureStatus GetDocumentPreview( 
   String^ FilePath,
   int ThumbnailWidth,
   int ThumbnailHeight,
   int BackColor,
   DocumentFormat% DocumentFormat,
   int% ThumbnailID,
   int% PageCount
) 

Parameters

FilePath
The full file path of the specified document.
ThumbnailWidth
The required width of the generated thumbnail of the first page, in pixels.
ThumbnailHeight
The required height of the generated thumbnail of the first page, in pixels.
BackColor
The required background color of the generated thumbnail, in ARGB format.
DocumentFormat
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
ThumbnailID
Output parameter. The unique image identifier of a newly generated thumbnail image of the first page of the specified document. Be aware that you need to subsequently release this image from memory using the DisposeImage method after you have used it.
PageCount
Output parameter. The total number of pages of the specified document.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is based on the GetDocumentFormat(String) method when processing the specified file.

Be aware that you need to release the thumbnail's image resource from memory using the DisposeImage method.

Example
How to retrieve extended information about the specified file.
Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
Dim thumbID As Integer = 0, pagesCount As Integer = 0
Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview("D:\\documents\\document.pdf", 100, 150, (Color.Aqua).ToArgb(), documentFormat, thumbID, pagesCount)
If status = GdPictureStatus.OK Then
    MessageBox.Show("Document Preview: " + vbCrLf + "  format: " + GdPicture14.DocumentFormat.ToString() + vbCrLf + "  number of pages: " + pagesCount.ToString(), "GdPicture")
Else
    MessageBox.Show("Error: " + status.ToString(), "GdPicture")
End If
'Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID)
GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
int thumbID = 0, pagesCount = 0;
GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview("D:\\documents\\document.pdf", 100, 150, (Color.Aqua).ToArgb(), ref documentFormat, ref thumbID, ref pagesCount);
if (status == GdPictureStatus.OK)
    MessageBox.Show("Document Preview: \n  format: " + GdPicture14.DocumentFormat.ToString() + "\n  number of pages: " + pagesCount.ToString(), "GdPicture");
else
    MessageBox.Show("Error: " + status.ToString(), "GdPicture");
//Do your stuff with thumbID here.
GdPictureDocumentUtilities.DisposeImage(thumbID);
See Also