The printer index. It must be a value from 1 to PrintGetPrintersCount.
Example





In This Topic
GdPicture14.WPF Namespace / GdViewer Class / PrintGetPrinterName Method

PrintGetPrinterName Method (GdViewer)

In This Topic
Returns the name of the printer according to the index you have specified.

You can use the PrintGetPrintersCount method to determine the number of all available printers. The printer index is simply an integer value from 1 to PrintGetPrintersCount.

Syntax
'Declaration

 

Public Function PrintGetPrinterName( _

   ByVal PrinterNo As Integer _

) As String
public string PrintGetPrinterName( 

   int PrinterNo

)
public function PrintGetPrinterName( 

    PrinterNo: Integer

): String; 
public function PrintGetPrinterName( 

   PrinterNo : int

) : String;
public: string* PrintGetPrinterName( 

   int PrinterNo

) 
public:

String^ PrintGetPrinterName( 

   int PrinterNo

) 

Parameters

PrinterNo
The printer index. It must be a value from 1 to PrintGetPrintersCount.

Return Value

The name of the specified printer. 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.
Example
How to find out the printer's name and how to use it further.
'We assume that the GdViewer1 control has been properly integrated.

Dim message As String = ""

Dim CurPrinter As String = GdViewer1.PrintGetActivePrinter()

If GdViewer1.GetStat() = GdPictureStatus.OK Then

    Dim PrintersCount As Integer = GdViewer1.PrintGetPrintersCount()

    If GdViewer1.GetStat() = GdPictureStatus.OK Then

        For i As Integer = 1 To PrintersCount

            Dim PrinterName As String = GdViewer1.PrintGetPrinterName(i)

            If GdViewer1.GetStat() = GdPictureStatus.OK Then

                If GdViewer1.PrintSetActivePrinter(PrinterName) = True Then

                    'You can find other printer settings here.

                    Dim PrnQuality As PrintQuality = GdViewer1.PrintGetQuality()

                    If GdViewer1.GetStat() = GdPictureStatus.OK Then

                        message = message + "Printer: " + PrinterName + "    Quality: " + PrnQuality.ToString() + vbCrLf

                    Else

                        message = message + "Printer: " + PrinterName + "    Error getting quality: " + GdViewer1.PrintGetStat().ToString() + vbCrLf

                    End If

                Else

                    Exit For

                End If

            Else

                Exit For

            End If

        Next

        If GdViewer1.GetStat() = GdPictureStatus.OK Then

            MessageBox.Show(message, "GdViewer.PrintGetPrinterName")

        Else

            MessageBox.Show("The example has NOT been followed successfully. The last status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName")

        End If

        If GdViewer1.PrintSetActivePrinter(CurPrinter) = False Then MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName")

    Else

        MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName")

    End If

Else

    MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName")

End If
//We assume that the GdViewer1 control has been properly integrated.

string message = "";

string CurPrinter = GdViewer1.PrintGetActivePrinter();

if (GdViewer1.GetStat() == GdPictureStatus.OK)

{

    int PrintersCount = GdViewer1.PrintGetPrintersCount();

    if (GdViewer1.GetStat() == GdPictureStatus.OK)

    {

        for (int i = 1; i <= PrintersCount; i++)

        {

            string PrinterName = GdViewer1.PrintGetPrinterName(i);

            if (GdViewer1.GetStat() == GdPictureStatus.OK)

            {

                if (GdViewer1.PrintSetActivePrinter(PrinterName) == true)

                {

                    //You can find other printer settings here.

                    PrintQuality PrnQuality = GdViewer1.PrintGetQuality();

                    if (GdViewer1.GetStat() == GdPictureStatus.OK)

                        message = message + "Printer: " + PrinterName + "    Quality: " + PrnQuality.ToString() + "\n";

                    else

                        message = message + "Printer: " + PrinterName + "    Error getting quality: " + GdViewer1.PrintGetStat().ToString() + "\n";

                }

                else

                    break;

            }

            else

                break;

        }

        if (GdViewer1.GetStat() == GdPictureStatus.OK)

            MessageBox.Show(message, "GdViewer.PrintGetPrinterName");

        else

            MessageBox.Show("The example has NOT been followed successfully. The last status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName");

        if (GdViewer1.PrintSetActivePrinter(CurPrinter) == false)

            MessageBox.Show("The PrintSetActivePrinter() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName");

    }

    else

        MessageBox.Show("The PrintGetPrintersCount() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName");

}

else

    MessageBox.Show("The PrintGetActivePrinter() method has failed with the status: " + GdViewer1.PrintGetStat(), "GdViewer.PrintGetPrinterName");
See Also