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





In This Topic
PrintGetActivePrinter Method (GdPicturePDF)
In This Topic
Returns the name of the printer, that is currently selected as the active printer, means the printer, which is subsequently used when printing the loaded PDF document.

It is mostly the default printer, if not set otherwise. However, you can use the PrintSetActivePrinter method to select your preferred printer for next print jobs without affecting any other installed printers.

Syntax
'Declaration
 
Public Function PrintGetActivePrinter() As String
public string PrintGetActivePrinter()
public function PrintGetActivePrinter(): String; 
public function PrintGetActivePrinter() : String;
public: string* PrintGetActivePrinter(); 
public:
String^ PrintGetActivePrinter(); 

Return Value

The name of the active printer to be used for subsequent printing. 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 printer, which name is returned by this method, is used to execute all subsequent print jobs and all subsequently altered printer settings are related to this printer. Likewise, none of the available printers or their properties are affected using any of the print methods of this class.

Example
How to find out the name of the currently selected printer on your computer.
Dim caption As String = "Example: PrintGetActivePrinter"
Using gdpicturePDF As New GdPicturePDF()
    Dim PrintersCount As Integer = gdpicturePDF.PrintGetPrintersCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim CurPrinter As String = gdpicturePDF.PrintGetActivePrinter()
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            MessageBox.Show("The number of available printers: " + PrintersCount.ToString() + vbCrLf +
                            "The currently selected printer is: " + CurPrinter, caption)
        Else
            MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
        End If
    Else
        MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption)
    End If
End Using
string caption = "Example: PrintGetActivePrinter";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    int PrintersCount = gdpicturePDF.PrintGetPrintersCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        string CurPrinter = gdpicturePDF.PrintGetActivePrinter();
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            MessageBox.Show("The number of available printers: " + PrintersCount.ToString() +
                            "\nThe currently selected printer is: " + CurPrinter, caption);
        else
            MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
    }
    else
        MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + gdpicturePDF.PrintGetStat(), caption);
}
See Also