Skip to main content

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.v23.2.dll

NuGet Package: DevExpress.Wpf.PdfViewer

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

View Example

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

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

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);
}
<Window
        xmlns:dxpdf="http://schemas.devexpress.com/winfx/2008/xaml/pdf"
        x:Class="SpecifyPrinterSettings.MainWindow"
        mc:Ignorable="d"
        Title="MainWindow" Height="350" Width="525">
        <dxpdf:PdfViewerControl x:Name="pdfViewer" 
                                DocumentLoaded="pdfViewer_DocumentLoaded"/>
</Window>
See Also