Utilities

Three common tasks are listing available printers, setting a print job's print priority, and printing to a file rather than a printer. Below are examples showing how to perform different printer related 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 Printer class has a GetLocalPrinters method that lists the locally installed printers.

public static Printer[] GetLocalPrinters()

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

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

The PrintJob class has a PrintPriority property that allows specifying a print job's priority (1-99). The following example demonstrates specifying a print job priority. A value between 1 and 99 sets the job priority, where 99 is the highest. By default, the PrintPriority property value 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

Rather then printing to a printer, the PrintToFileName property allows printing to a file rather than a printer. The following example demonstrates how to redirect a PDF document to a file instead of printing a document.

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()  

GitHub

Refer to the print-manager-dotnet-core project on GitHub for examples demonstrating how to use the DynamicPDF PrintManager for .NET.

In this topic