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





In This Topic
PrintGetDocumentName Method (GdPicturePDF)
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.
Dim caption As String = "Example: PrintGetDocumentName"
Using gdpicturePDF As New GdPicturePDF()
    If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
        Dim docName As String = gdpicturePDF.PrintGetDocumentName()
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            Dim status As GdPictureStatus = GdPictureStatus.OK
            Dim curName As String = gdpicturePDF.GetTitle()
            If String.IsNullOrEmpty(curName) = False Then
                'We only change the document name if the document title is not empty.
                gdpicturePDF.PrintSetDocumentName(curName)
                status = gdpicturePDF.GetStat()
            End If
            If status = GdPictureStatus.OK Then
                If gdpicturePDF.Print() = GdPictureStatus.OK Then
                    MessageBox.Show("The file " + curName + " has been printed successfully.", caption)
                Else
                    Dim message As String = "The file " + curName + " can't be printed." + vbCrLf + "Status: " + gdpicturePDF.PrintGetStat().ToString()
                    If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
                        message = message + "    Error: " + gdpicturePDF.PrintGetLastError()
                    End If
                    MessageBox.Show(message, caption)
                End If
            Else
                MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption)
            End If
        Else
            MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption)
        End If
        gdpicturePDF.CloseDocument()
    Else
        MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: PrintGetDocumentName";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
    {
        string docName = gdpicturePDF.PrintGetDocumentName();
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            GdPictureStatus status = GdPictureStatus.OK;
            string curName = gdpicturePDF.GetTitle();
            if (String.IsNullOrEmpty(curName) == false)
            {
                //We only change the document name if the document title is not empty.
                status = gdpicturePDF.PrintSetDocumentName(curName);
                if (status == GdPictureStatus.OK)
                    docName = curName;
            }
            if (status == GdPictureStatus.OK)
            {
                if (gdpicturePDF.Print() == GdPictureStatus.OK)
                {
                    MessageBox.Show("The file " + docName + " has been printed successfully.", caption);
                }
                else
                {
                    string message = "The file " + docName + " can't be printed.\nStatus: " + gdpicturePDF.PrintGetStat().ToString();
                    if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
                        message = message + "    Error: " + gdpicturePDF.PrintGetLastError();
                    MessageBox.Show(message, caption);
                }
            }
            else
            {
                MessageBox.Show("The PrintSetDocumentName() method has failed with the status: " + status, caption);
            }
        }
        else
        {
            MessageBox.Show("The PrintGetDocumentName() method has failed with the status: " + gdpicturePDF.GetStat(), caption);
        }
        gdpicturePDF.CloseDocument();
    }
    else
    {
        MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
}
See Also