GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / PrintGetDocumentName Method
Example





In This Topic
PrintGetDocumentName Method (GdViewer)
In This Topic
Returns the printer document name setting of the active printer. You can use it to display during the next print process (for example, in a print status dialog box or printer queue) while printing the document.
Syntax
'Declaration
 
Public Function PrintGetDocumentName() As String
public string PrintGetDocumentName()
public function PrintGetDocumentName(): String; 
public function PrintGetDocumentName() : String;
public: string* PrintGetDocumentName(); 
public:
String^ PrintGetDocumentName(); 

Return Value

The value of the active printer document name setting. The GetStat method can be subsequently used or the PrintGetStat method to determine if this method has been successful.
Remarks
It is recommend to use the GetStat method or the PrintGetStat method to identify the specific reason for the method's failure, if any.

Just to inform you that the default value specified by the toolkit is "GdPicture Print Process".

Likewise to remind you that the active printer is the printer identified by the PrintGetActivePrinter method or set by the PrintSetActivePrinter method and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.

Example
How to find out the document name property of the active printer and how to use it further.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    Dim docName As String = GdViewer1.PrintGetDocumentName()
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        Dim status As GdPictureStatus = GdPictureStatus.OK
        Dim curName As String = GdViewer1.GetLastPath()
        If String.IsNullOrEmpty(curName) = False Then
            'We only change the document name if the current file path (the last path) is not empty.
            status = GdViewer1.PrintSetDocumentName(curName)
            If status = GdPictureStatus.OK Then docName = curName
        End If
        If status = GdPictureStatus.OK Then
            If GdViewer1.Print() = GdPictureStatus.OK Then
                MessageBox.Show("The file " + docName + " has been printed successfully.", "GdViewer.PrintGetDocumentName")
            Else
                Dim message As String = "The file " + docName + " can't be printed." + vbCrLf + "Status: " + GdViewer1.PrintGetStat().ToString()
                If GdViewer1.PrintGetStat() = GdPictureStatus.PrintingException Then message = message + "    Error: " + GdViewer1.PrintGetLastError()
                MessageBox.Show(message, "GdViewer.PrintGetDocumentName")
            End If
        Else
            MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, "GdViewer.PrintGetDocumentName")
        End If
    Else
        MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + GdViewer1.GetStat(), "GdViewer.PrintGetDocumentName")
    End If
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintGetDocumentName")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    string docName = GdViewer1.PrintGetDocumentName();
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        GdPictureStatus status = GdPictureStatus.OK;
        string curName = GdViewer1.GetLastPath();
        if (String.IsNullOrEmpty(curName) == false)
        {
            //We only change the document name if the current file path (the last path) is not empty.
            status = GdViewer1.PrintSetDocumentName(curName);
            if (status == GdPictureStatus.OK)
                docName = curName;
        }
        if (status == GdPictureStatus.OK)
        {
            if (GdViewer1.Print() == GdPictureStatus.OK)
            {
                MessageBox.Show("The file " + docName + " has been printed successfully.", "GdViewer.PrintGetDocumentName");
            }
            else
            {
                string message = "The file " + docName + " can't be printed.\nStatus: " + GdViewer1.PrintGetStat().ToString();
                if (GdViewer1.PrintGetStat() == GdPictureStatus.PrintingException)
                    message = message + "    Error: " + GdViewer1.PrintGetLastError();
                MessageBox.Show(message, "GdViewer.PrintGetDocumentName");
            }
        }
        else
        {
            MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, "GdViewer.PrintGetDocumentName");
        }
    }
    else
    {
        MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + GdViewer1.GetStat(), "GdViewer.PrintGetDocumentName");
    }
    GdViewer1.CloseDocument();
}
else
{
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintGetDocumentName");
}
See Also