Skip to main content

Utilities

Version: 3.0

Utilities

Below are some miscellaneous examples that show how to perform various tasks. These examples demonstrate how to retrieve a list of installed printers, set print job priority, send a fax and print to file.

List Installed Printers​

The example below demonstrates how to retrieve a list of all printers (includes network printers for which a driver is installed).

Printer[] printerList = Printer.GetLocalPrinters();
Dim printerList As Printer() = Printer.GetLocalPrinters()

The example below demonstrates how to specify priority for a print job. A value between 1 and 99 can be used to set the job priority with 99 being the highest priority. By default, the value of PrintPriority property is set to 1. When the Windows print spooler receives multiple jobs with different priorities it prioritizes the spooled jobs with the highest print priority value.

InputPdf pdf = new InputPdf(pdfFilePath);
PrintJob printJob = new PrintJob(Printer.Default, pdf);
printJob.PrintPriority = 10;
printJob.Print();
Dim pdf As InputPdf = New InputPdf(pdfFilePath)
Dim printJob As PrintJob = New PrintJob(Printer.Default, pdf)
printJob.PrintPriority = 10
printJob.Print()

Redirect to File​

The below example demonstrates how to redirect a PDF document to a file instead of actual printing.

PrintJob printJob = new PrintJob(Printer.Default, pdfFilePath);
printJob.PrintToFileName = prnFilePath;
printJob.Print();
Dim printJob As New PrintJob(Printer.Default, pdfFilePath)
printJob.PrintToFileName = prnFilePath
printJob.Print()