PrintGetPrinterName Method (GdPictureImaging)
Returns the name of the printer according to the index you have specified.
You can use the GdPictureImaging.PrintGetPrintersCount method to determine the number of all available printers. The printer index is simply an integer value from 1 to GdPictureImaging.PrintGetPrintersCount.
public string PrintGetPrinterName(
int
)
public function PrintGetPrinterName(
: Integer
): String;
public function PrintGetPrinterName(
: int
) : String;
public: string* PrintGetPrinterName(
int
)
public:
String^ PrintGetPrinterName(
int
)
'Declaration
Public Function PrintGetPrinterName( _
ByVal As Integer _
) As String
Parameters
- PrinterNo
- The printer index. It must be a value from 1 to GdPictureImaging.PrintGetPrintersCount.
Return Value
The name of the specified printer.
Finding out the name of the active printer.
Listing of all available printers.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string printers = "The number of printers: " + printCount + ".\n";
for (int i = 1; i<=printCount; i++)
{
printers += gdpictureImaging.PrintGetPrinterName(i) + "\n";
}
MessageBox.Show(printers, "Available printers", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Changing the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
int printCount = gdpictureImaging.PrintGetPrintersCount();
string message = "The number of printers: " + printCount;
if (printCount > 0)
{
gdpictureImaging.PrintSetActivePrinter(gdpictureImaging.PrintGetPrinterName(1));
message += "\nThe active printer is: " + gdpictureImaging.PrintGetActivePrinter();
}
MessageBox.Show(message, "Active printer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}