GdPicture.NET.14
GdPicture14 Namespace / GdPictureDocumentUtilities Class / GetDocumentPreview Method / GetDocumentPreview(Stream,String,DocumentFormat,Int32) Method
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.
The name of the original file. It can be an empty string. Providing this parameter can help the format detection algorithm to distinguish format using the same signature pattern.
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
Output parameter. The total number of pages of the specified document.
Example





In This Topic
GetDocumentPreview(Stream,String,DocumentFormat,Int32) Method
In This Topic
Retrieves the format of a required document and the total number of pages of that document. The specified document is accessible from a previously instantiated Stream object.
Syntax
'Declaration
 
Public Overloads Shared Function GetDocumentPreview( _
   ByVal FileStream As Stream, _
   ByVal FileName As String, _
   ByRef DocumentFormat As DocumentFormat, _
   ByRef PageCount As Integer _
) As GdPictureStatus
public static GdPictureStatus GetDocumentPreview( 
   Stream FileStream,
   string FileName,
   ref DocumentFormat DocumentFormat,
   ref int PageCount
)
public function GetDocumentPreview( 
    FileStream: Stream;
    FileName: String;
   var  DocumentFormat: DocumentFormat;
   var  PageCount: Integer
): GdPictureStatus; static; 
public static function GetDocumentPreview( 
   FileStream : Stream,
   FileName : String,
   DocumentFormat : DocumentFormat,
   PageCount : int
) : GdPictureStatus;
public: static GdPictureStatus GetDocumentPreview( 
   Stream* FileStream,
   string* FileName,
   ref DocumentFormat DocumentFormat,
   ref int PageCount
) 
public:
static GdPictureStatus GetDocumentPreview( 
   Stream^ FileStream,
   String^ FileName,
   DocumentFormat% DocumentFormat,
   int% PageCount
) 

Parameters

FileStream
A System.IO.Stream object. This stream object must be initialized before it can be sent into this method and it should remain open for subsequent use. At the same, the provided stream object must support seeking, otherwise the method will fail.
FileName
The name of the original file. It can be an empty string. Providing this parameter can help the format detection algorithm to distinguish format using the same signature pattern.
DocumentFormat
Output parameter. A member of the DocumentFormat enumeration. The format of the specified document.
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(Stream,String) method when processing the specified stream.

Be aware that the specified stream should remain open during running this method and it needs to be closed by the user as well. At the same, the provided stream must support seeking, otherwise the method will fail.

Example
How to retrieve basic information of an image file stored within a stream.
Using fileStream As FileStream = New FileStream("input.tif", FileMode.Open)
    Dim documentFormat As GdPicture14.DocumentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN
    Dim pagesCount As Integer = 0
    Dim status As GdPictureStatus = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", documentFormat, 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
End Using
using (FileStream fileStream = new FileStream("input.tif", FileMode.Open))
{
    GdPicture14.DocumentFormat documentFormat = GdPicture14.DocumentFormat.DocumentFormatUNKNOWN;
    int pagesCount = 0;
    GdPictureStatus status = GdPictureDocumentUtilities.GetDocumentPreview(fileStream, "input.tif", ref documentFormat, 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");
}
See Also