Skip to main content
A newer version of this page is available. .

PdfViewerControl.Print(PdfPrinterSettings, Boolean) Method

Prints a document using the specified PDF print settings without invoking the Print dialog.

Namespace: DevExpress.Xpf.PdfViewer

Assembly: DevExpress.Xpf.PdfViewer.v19.2.dll

Declaration

public virtual void Print(
    PdfPrinterSettings printerSettings,
    bool showPrintStatus = true
)

Parameters

Name Type Description
printerSettings PdfPrinterSettings

A PdfPrinterSettings value, specifying the PDF printing options.

Optional Parameters

Name Type Default Description
showPrintStatus Boolean True

true, to show the printing status; otherwise, false.

Example

Note

The complete sample project is available at https://github.com/DevExpress-Examples/how-to-use-pdf-printer-settings

This example shows how to print a document with custom printer settings.

using System.Drawing.Printing;
using System.Windows;
using DevExpress.Pdf;

namespace SpecifyPrinterSettings {
    public partial class MainWindow : Window {
        public MainWindow() {
            InitializeComponent();

            // Load a PDF document.
            pdfViewer.OpenDocument(@"..\..\Demo.pdf");
        }

        private void pdfViewer_DocumentLoaded(object sender, RoutedEventArgs e) {
            // If required, declare and specify the system printer settings.
            PrinterSettings printerSettings = new PrinterSettings();
            printerSettings.PrinterName = "Microsoft XPS Document Writer";
            printerSettings.PrintToFile = true;
            printerSettings.PrintFileName = @"..\..\Demo.xps";

            // Declare the PDF printer settings.
            // If required, pass the system settings to the PDF printer settings constructor.
            PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings(printerSettings);

            // Specify the PDF printer settings.
            pdfPrinterSettings.PageOrientation = PdfPrintPageOrientation.Auto;
            pdfPrinterSettings.PageNumbers = new int[] { 1, 3, 4, 5 };
            pdfPrinterSettings.ScaleMode = PdfPrintScaleMode.CustomScale;
            pdfPrinterSettings.Scale = 90;

            // Print the document using the specified printer settings and show print status parameter.            
            pdfViewer.Print(pdfPrinterSettings, true);
        }
    }
}
See Also