GdPicture.NET.14
GdPicture14.WPF Namespace / GdViewer Class / PrintGetLastError Method
Example





In This Topic
PrintGetLastError Method (GdViewer)
In This Topic
Returns the error description of the last executed print operation, that has failed specifically with the GdPictureStatus.PrintingException error.
Syntax
'Declaration
 
Public Function PrintGetLastError() As String
public string PrintGetLastError()
public function PrintGetLastError(): String; 
public function PrintGetLastError() : String;
public: string* PrintGetLastError(); 
public:
String^ PrintGetLastError(); 

Return Value

The description of the last printing error.
Remarks
The value resets to its default (an empty string) starting each new print job.
Example
How to properly check the returned status when printing the currently displayed document.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    If GdViewer1.Print(PrintSizeOption.PrintSizeOptionActual) = GdPictureStatus.OK Then
        MessageBox.Show("The file has been printed successfully.", "GdViewer.PrintGetLastError")
    Else
        Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + GdViewer1.PrintGetStat().ToString()
        If GdViewer1.PrintGetStat() = GdPictureStatus.PrintingException Then message = message + "    Error: " + GdViewer1.PrintGetLastError()
        MessageBox.Show(message, "GdViewer.PrintGetLastError")
    End If
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintGetLastError")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    if (GdViewer1.Print(PrintSizeOption.PrintSizeOptionActual) == GdPictureStatus.OK)
    {
        MessageBox.Show("The file has been printed successfully.", "GdViewer.PrintGetLastError");
    }
    else
    {
        string message = "The file can't be printed.\nStatus: " + GdViewer1.PrintGetStat().ToString();
        if (GdViewer1.PrintGetStat() == GdPictureStatus.PrintingException)
            message = message + "    Error: " + GdViewer1.PrintGetLastError();
        MessageBox.Show(message, "GdViewer.PrintGetLastError");
    }
    GdViewer1.CloseDocument();
}
else
{
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintGetLastError");
}
See Also