GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / PrintSetDocumentName Method
The new value of the printer document name setting.
Example





In This Topic
PrintSetDocumentName Method (GdViewer)
In This Topic
Sets up 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 PrintSetDocumentName( _
   ByVal DocumentName As String _
) As GdPictureStatus
public GdPictureStatus PrintSetDocumentName( 
   string DocumentName
)
public function PrintSetDocumentName( 
    DocumentName: String
): GdPictureStatus; 
public function PrintSetDocumentName( 
   DocumentName : String
) : GdPictureStatus;
public: GdPictureStatus PrintSetDocumentName( 
   string* DocumentName
) 
public:
GdPictureStatus PrintSetDocumentName( 
   String^ DocumentName
) 

Parameters

DocumentName
The new value of the printer document name setting.

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
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.PrintSetDocumentName")
            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.PrintSetDocumentName")
            End If
        Else
            MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, "GdViewer.PrintSetDocumentName")
        End If
    Else
        MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + GdViewer1.GetStat(), "GdViewer.PrintSetDocumentName")
    End If
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintSetDocumentName")
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.PrintSetDocumentName");
            }
            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.PrintSetDocumentName");
            }
        }
        else
        {
            MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, "GdViewer.PrintSetDocumentName");
        }
    }
    else
    {
        MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + GdViewer1.GetStat(), "GdViewer.PrintSetDocumentName");
    }
    GdViewer1.CloseDocument();
}
else
{
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintSetDocumentName");
}
See Also