The file path of the document to display. Use the empty string to allow the control to prompts users to select a file.

You can subsequently use the GetLastPath method to retrieve the path of the selected file.

Optional parameter. If provided, specifies the password to be used to decrypt the specified PDF document allowing the control to read its content.

Example





In This Topic
GdPicture14.WPF Namespace / GdViewer Class / DisplayFromFile Method

DisplayFromFile Method (GdViewer)

In This Topic
Loads a document from a file according to a file path you have specified and subsequently displays it in the GdViewer control. The document previously displayed in the control will automatically close.

All document formats currently supported by the toolkit are listed here.

The BeforeDocumentChange and the AfterDocumentChange events are raised just before and right after the document is displayed in the GdViewer control. Both events are only raised if the document has been successfully loaded.

Loads documents or images from a file and subsequently displays it in the GdViewer control.
Syntax
'Declaration
 
Public Function DisplayFromFile( _
   ByVal FilePath As String, _
   Optional ByVal Password As String _
) As GdPictureStatus
public GdPictureStatus DisplayFromFile( 
   string FilePath,
   string Password
)
public function DisplayFromFile( 
    FilePath: String;
    Password: String
): GdPictureStatus; 
public function DisplayFromFile( 
   FilePath : String,
   Password : String
) : GdPictureStatus;
public: GdPictureStatus DisplayFromFile( 
   string* FilePath,
   string* Password
) 
public:
GdPictureStatus DisplayFromFile( 
   String^ FilePath,
   String^ Password
) 

Parameters

FilePath
The file path of the document to display. Use the empty string to allow the control to prompts users to select a file.

You can subsequently use the GetLastPath method to retrieve the path of the selected file.

Password

Optional parameter. If provided, specifies the password to be used to decrypt the specified PDF document allowing the control to read its content.

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
Just to remind you that you can use the empty string as a FilePath parameter to allow the control to pop up the File Open dialog box. You can later use the GetLastPath method to retrieve the full file path of the selected file.

Likewise, both the BeforeDocumentChange and the AfterDocumentChange events are raised using this method.

Example
How to display a document loaded from a single file.
'We assume that the GdViewer1 control has been properly integrated.
'The File Open dialog box will pop up to select a file.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    MessageBox.Show("The selected file is: " + GdViewer1.GetLastPath(), "GdViewer.DisplayFromFile")
    'Do your stuff here.
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromFile")
End If
//We assume that the GdViewer1 control has been properly integrated.
//The File Open dialog box will pop up to select a file.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    MessageBox.Show("The selected file is: " + GdViewer1.GetLastPath(), "GdViewer.DisplayFromFile");
    //Do your stuff here.
    GdViewer1.CloseDocument();
}
else
{
    MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromFile");
}
See Also