Reference Guide
GdPicture14 Namespace / GdPicturePDF Class / PrintSetActivePrinter Method
The name of the printer you want to set up as an active printer to be used for subsequent printing.
Example





In This Topic
    PrintSetActivePrinter Method (GdPicturePDF)
    In This Topic
    Sets the printer, identified by its name, as the active printer, that means makes it the currently selected printer, which is subsequently used when printing the loaded PDF document. The specified printer is used to execute all next print jobs using the print methods of this class, if not set otherwise, without affecting any other installed printers.

    You can use the PrintGetActivePrinter method to retrieve the currently selected printer, denoted as the active printer for print methods of this class. At the same this printer utilizes all by you altered printer settings without affecting the installed printers.

    Syntax
    'Declaration
     
    
    Public Function PrintSetActivePrinter( _
       ByVal PrinterName As String _
    ) As Boolean
    public bool PrintSetActivePrinter( 
       string PrinterName
    )
    public function PrintSetActivePrinter( 
        PrinterName: String
    ): Boolean; 
    public function PrintSetActivePrinter( 
       PrinterName : String
    ) : boolean;
    public: bool PrintSetActivePrinter( 
       string* PrinterName
    ) 
    public:
    bool PrintSetActivePrinter( 
       String^ PrinterName
    ) 

    Parameters

    PrinterName
    The name of the printer you want to set up as an active printer to be used for subsequent printing.

    Return Value

    true if the method has been followed successfully, otherwise false.

    Please use the GetStat method or the PrintGetStat method to determine the specific reason for the method's failure.

    Remarks
    Just to inform you, that the printer selected 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 printer settings for all available printers.
    Dim caption As String = "Example: PrintSetActivePrinter"
    Using oGdPicturePDF As New GdPicturePDF()
        Dim message As String = ""
        Dim CurPrinter As String = oGdPicturePDF.PrintGetActivePrinter()
        If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
            Dim PrintersCount As Integer = oGdPicturePDF.PrintGetPrintersCount()
            If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
                For i As Integer = 1 To PrintersCount
                    Dim PrinterName As String = oGdPicturePDF.PrintGetPrinterName(i)
                    If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
                        If oGdPicturePDF.PrintSetActivePrinter(PrinterName) = True Then
                            Dim prnSettings As System.Drawing.Printing.PrinterSettings
                            prnSettings = oGdPicturePDF.PrintGetPrinterSettings()
                            If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
                                message = message + "Printer: " + PrinterName + vbCrLf + "Settings: " + prnSettings.ToString() + vbCrLf + vbCrLf
                            Else
                                message = message + "Printer: " + PrinterName + "    Error getting settings: " + oGdPicturePDF.PrintGetStat().ToString() + vbCrLf
                            End If
                        Else
                            Exit For
                        End If
                    Else
                        Exit For
                    End If
                Next
                If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
                    MessageBox.Show(message, caption)
                Else
                    MessageBox.Show("The example has NOT been followed successfully. The last status: " + oGdPicturePDF.PrintGetStat(), caption)
                End If
                If oGdPicturePDF.PrintSetActivePrinter(CurPrinter) = False Then
                    MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + oGdPicturePDF.PrintGetStat(), caption)
                End If
            Else
                MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + oGdPicturePDF.PrintGetStat(), caption)
            End If
        Else
            MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + oGdPicturePDF.PrintGetStat(), caption)
        End If
    End Using
    string caption = "Example: PrintSetActivePrinter";
    using (GdPicturePDF oGdPicturePDF = new GdPicturePDF())
    {
        string message = "";
        string CurPrinter = oGdPicturePDF.PrintGetActivePrinter();
        if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
        {
            int PrintersCount = oGdPicturePDF.PrintGetPrintersCount();
            if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
            {
                for (int i = 1; i <= PrintersCount; i++)
                {
                    string PrinterName = oGdPicturePDF.PrintGetPrinterName(i);
                    if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
                    {
                        if (oGdPicturePDF.PrintSetActivePrinter(PrinterName) == true)
                        {
                            System.Drawing.Printing.PrinterSettings prnSettings;
                            prnSettings = oGdPicturePDF.PrintGetPrinterSettings();
                            if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
                                message = message + "Printer: " + PrinterName + "\nSettings: " + prnSettings.ToString() + "\n\n";
                            else
                                message = message + "Printer: " + PrinterName + "    Error getting settings: " + oGdPicturePDF.PrintGetStat().ToString() + "\n";
                        }
                        else
                            break;
                    }
                    else
                        break;
                }
                if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
                    MessageBox.Show(message, caption);
                else
                    MessageBox.Show("The example has NOT been followed successfully. The last status: " + oGdPicturePDF.PrintGetStat(), caption);
                if (oGdPicturePDF.PrintSetActivePrinter(CurPrinter) == false)
                    MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + oGdPicturePDF.PrintGetStat(), caption);
            }
            else
                MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + oGdPicturePDF.PrintGetStat(), caption);
        }
        else
            MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + oGdPicturePDF.PrintGetStat(), caption);
    }
    See Also