Overview

The DynamicPDF PrintManager API is straightforward yet still provides a rich feature set for printing PDF documents. When using the PrintManager API, you can make your applications as easy or as complex as desired. Developers new to the component will find that understanding the object model comes quickly while adding PDF printing functionality to your .NET application has never been easier.

Understanding DynamicPDF PrintManager API requires understanding three primary classes; the PrintJob class, the Printer class, and the PrintOptions class.

The PrintJob Class

The main class required to use the PrintManager API is the PrintJob class. The PrintJob is where you 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 manage events (print success, print failure, update, etc.) associated with a print job.

The Printer Class

Use the Printer class to determine supported features and functions of a specified printer. The Printer class does not typically need to be instantiated individually but can be accessed directly as a property of the PrintJob class. The Printer class properties are read-only and simply show what a certain printer capabilities. 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

The PrintOptions class sets the specific options that the PrintJob uses to send a PDF document(s) to the printer. The PrintOptions class is accessed from the PrintJob class (PrintJob.PrintOptions). The PrintOptions is where developers 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 a file to the printer.

Example

The following code illustrates using these three classes. It shows sending a PDF document to the default printer, checking to see if that printer supports duplex printing, and setting a 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()

In this topic