Skip to main content

Overview

Version: 1.0

DynamicPDF PrintManager For .NET Overview

The PrintManager API is very easy to use while at the same time it provides a huge feature set for printing PDF documents. Developers new to the component will find that understanding the object model comes very quickly and adding PDF printing functionality to your .NET application has never been easier.

A basic understanding of the PrintManager API can be had by getting to know 3 main classes; the PrintJob class, the Printer class and the PrintOptions class. These three are explained below.

The PrintJob Class​

The main class you need to use is the PrintJob class. The PrintJob is where you will specify the PDF document(s), the printer and the print options to use when sending the job to the actual printer. This is also where you can manage events (print success, print failure, update, etc.) associated with that print job.

The Printer Class​

Determining the supported features and functions of a specified printer is all done via the Printer class. The Printer class does not typically need to be instantiated individually but can be accessed directly as a property of the PrintJob class. The properties of the Printer class are read-only and simply show what a certain printer can handle. For instance you can tell if a printer can print in color, if a printer supports duplex or what paper sizes are available. Reading the Printer properties is similar to opening the printer’s properties dialog box to see what is or is not available for that printer.

The PrintOptions Class​

Setting up the specific options that the PrintJob will use to send the PDF document(s) to the printer is done in the PrintOptions class. The PrintOptions class is accessed off of the PrintJob class (PrintJob.PrintOptions). The PrintOptions is where developers can specify options such as a certain duplex mode to use (if supported by your printer) or the orientation or scaling of the print job. Setting the PrintOptions is the programmatic equivalent of selecting certain options from the print dialog box when manually sending your file to the printer.

Example​

A good example that illustrates these three classes is written below. This shows sending a PDF document to the default printer, checking to see if that printer supports duplex printing and if it does then setting the print job to print in vertical duplex mode.

PrintJob printJob = new PrintJob(Printer.Default, "C:\\Temp\\Print.pdf");
if (printJob.Printer.Duplex)
printJob.PrintOptions.DuplexMode = DuplexMode.DuplexVertical;
printJob.Print();
Dim MyPrintJob As New PrintJob(Printer.Default, "C:\\Temp\\Print.pdf")
If (MyPrintJob.Printer.Duplex) Then
MyPrintJob.PrintOptions.DuplexMode = DuplexMode.DuplexVertical
End If
MyPrintJob.Print()