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
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.
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