GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / DisplayFromHTTP Method / DisplayFromHTTP(String,String,Int32) Method
The name of the host server, where the file is located, for example http://www.gdpicture.com.
The file path on the host server for the document to display, for example /demo/image.jpg.
The HTTP port number used. It is usually 80 for usage of the HTTP or 443 for usage of the HTTPS transfer mode.
Example





In This Topic
DisplayFromHTTP(String,String,Int32) Method
In This Topic
Loads a document from a file stored on a distant server using HTTP transfer according to what you have specified and subsequently displays it in the GdViewer control. The file transfer will be run asynchronously. The document previously displayed in the control will automatically close.

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

The DataReceived event is raised to allow you to monitor the transferred data. Likewise, the TransferEnded event is raised right after the transfer will finish.

You can also control displaying the progress bar by enabling or disabling the EnabledProgressBar property.

Syntax
'Declaration
 
Public Overloads Function DisplayFromHTTP( _
   ByVal Host As String, _
   ByVal Path As String, _
   ByVal HTTPPort As Integer _
) As GdPictureStatus
public GdPictureStatus DisplayFromHTTP( 
   string Host,
   string Path,
   int HTTPPort
)
public function DisplayFromHTTP( 
    Host: String;
    Path: String;
    HTTPPort: Integer
): GdPictureStatus; 
public function DisplayFromHTTP( 
   Host : String,
   Path : String,
   HTTPPort : int
) : GdPictureStatus;
public: GdPictureStatus DisplayFromHTTP( 
   string* Host,
   string* Path,
   int HTTPPort
) 
public:
GdPictureStatus DisplayFromHTTP( 
   String^ Host,
   String^ Path,
   int HTTPPort
) 

Parameters

Host
The name of the host server, where the file is located, for example http://www.gdpicture.com.
Path
The file path on the host server for the document to display, for example /demo/image.jpg.
HTTPPort
The HTTP port number used. It is usually 80 for usage of the HTTP or 443 for usage of the HTTPS transfer mode.

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.

Use the GetLastTransferError method to diagnose the error if this method has failed with one of the GdPictureStatus.Internet... errors.

Remarks
Just to remind you that both the DataReceived event and the TransferEnded event are raised to allow you to monitor the transfer progress.

Likewise, you can also utilize both the BeforeDocumentChange and the AfterDocumentChange events using this method.

Example
How to display your image from a distant server using the HTTP transfer.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromHTTP("www.mywebsite.com", "/demo/image.tif", 443) = GdPictureStatus.OK Then
    'Do your stuff here.
Else
    If GdViewer1.GetStat() = GdPictureStatus.InternetConnectError Then
        'Use the GetLastTransferError() method here to find the reason for the failure.
        MessageBox.Show("Internet connection error: " + GdViewer1.GetLastTransferError(), "GdViewer.DisplayFromHTTP")
    Else
        MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromHTTP")
    End If
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromHTTP("www.mywebsite.com", "/demo/image.tif", 443) == GdPictureStatus.OK)
{
    //Do your stuff here.
}
else
{
    if (GdViewer1.GetStat() == GdPictureStatus.InternetConnectError)
        //Use the GetLastTransferError() method here to find the reason for the failure.
        MessageBox.Show("Internet connection error: " + GdViewer1.GetLastTransferError(), "GdViewer.DisplayFromHTTP");
    else
        MessageBox.Show("This file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.DisplayFromHTTP");
}
See Also