Print Options

The following examples illustrate printing a PDF using different print options. Print options can be set for the entire print job or for each page within the print job.

Print Job Print Options

This example demonstrates how to send a particular PDF document to a printer while setting the document to print 2 copies, print in color, and scaling to actual size, and printing without annotations.

To set a particular PrintJob option, use the PrintOption's properties (i.e. printJob.PrintOptions.Color). If however, you wished to check if a particular printer supports a certain feature, you can do this by checking the printer's properties (i.e. printJob.Printer.Color).

Note that setting options on an unsupported print job (in the PrintOptions class) causes the specified printer to throw an exception. For example, setting PrintJob.PrintOptions.Color to true when a specified printer does not support color results in a thrown exception.

PrintJob printJob = new PrintJob(Printer.Default, pdfFilePath);

if (printJob.Printer.Color)
    printJob.PrintOptions.Color = true;
    
printJob.PrintOptions.Copies = 2;
printJob.PrintOptions.Scaling = PageScaling.ActualSize; // Can also use AutoPageScaling or PercentagePageScaling objects
printJob.PrintOptions.PrintAnnotations = false;

printJob.Print();       
Dim MyPrintJob As New PrintJob(Printer.Default, pdfFilePath)

If (MyPrintJob.Printer.Color) Then
    MyPrintJob.PrintOptions.Color = True
End If

MyPrintJob.PrintOptions.Copies = 2
MyPrintJob.PrintOptions.Scaling = PageScaling.ActualSize ' Can also use AutoPageScaling or PercentagePageScaling objects
MyPrintJob.PrintOptions.PrintAnnotations = False

MyPrintJob.Print()

Page Level Print Options

This example demonstrates overriding global print options for a specific page within a print job using PrintJobPagePrintOptions class.

Note that the PrintJobPagePrintOptions.Inherit property must be set to false before updating the print options for that page. Also, not all print options available at the global level are also available at the page level. Properties such as Color, Copies, Collate, DuplexMode & Resolution are not available at the page level. These properties can only be set for an entire print job.

PrintJob printJob = new PrintJob(Printer.Default, pdfFilePath);
//Set the print options for the entire print job.
if (printJob.Printer.Color)
   printJob.PrintOptions.Color = true;
                        
printJob.PrintOptions.Copies = 2;
printJob.PrintOptions.Scaling = PageScaling.ActualSize;
printJob.PrintOptions.PrintAnnotations = false;
                        
//Get the last page and set its print options.
PrintJobPage printJobPage = printJob.Pages[printJob.Pages.Count - 1];
PrintJobPagePrintOptions pagePrintOptions = printJobPage.PrintOptions;
                        
//Set Inherit property to false in order to change the print options for a specific page.
pagePrintOptions.Inherit = false;
pagePrintOptions.Scaling = new PercentagePageScaling(0.5f);
pagePrintOptions.HorizontalAlign = HorizontalAlign.Left;
pagePrintOptions.PrintAnnotations = true;
printJob.Print();        
Dim printJob As New PrintJob(Printer.Default, pdfFilePath)
'Set the print options for the entire print job.
If (printJob.Printer.Color) Then
   printJob.PrintOptions.Color = True
End If
			
printJob.PrintOptions.Copies = 2
printJob.PrintOptions.Scaling = PageScaling.ActualSize
printJob.PrintOptions.PrintAnnotations = False
			
'Get the last page and set its print options.
Dim printJobPage As PrintJobPage = printJob.Pages(printJob.Pages.Count - 1)
Dim pagePrintOptions As PrintJobPagePrintOptions = printJobPage.PrintOptions
			
'Set Inherit property to false in order to change the print options for a specific page.
pagePrintOptions.Inherit = False
pagePrintOptions.Scaling = New PercentagePageScaling(0.5F)
pagePrintOptions.HorizontalAlign = HorizontalAlign.Left
pagePrintOptions.PrintAnnotations = True
printJob.Print()

In this topic