Skip to main content

XpfRichEditPrinter Class

Provides the functionality to implement your custom printing logic.

Namespace: DevExpress.XtraRichEdit.Printing

Assembly: DevExpress.Xpf.RichEdit.v24.1.dll

NuGet Package: DevExpress.Wpf.RichEdit

Declaration

public class XpfRichEditPrinter :
    RichEditPrinterBase

Remarks

The XpfRichEditPrinter class provides two methods: Print, allowing you to print to the default printer; and PrintDialog which invokes the Print dialog.

You can create a XpfRichEditPrinter class descendant and implement you custom printing logic, as shown in the code snippet below:

Example

using System.Printing;
using System.Windows;
using System.Windows.Controls;
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.Printing;
using System.Windows.Documents;
using System.Drawing.Printing;
    public class CustomXpfRichEditPrinter : XpfRichEditPrinter
    {
        public CustomXpfRichEditPrinter(IRichEditControl control)
            : base(control) {}

        public void PrintToMyPrinter()
        {
            PrintDialog pDialog = new PrintDialog();
            PrintQueueCollection queues = new PrintServer().GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local,
                EnumeratedPrintQueueTypes.Connections });
            System.Collections.IEnumerator localPrinterEnumerator = queues.GetEnumerator();
            PrintQueue printQueue = null;

            if (localPrinterEnumerator.MoveNext()) {
                printQueue = (PrintQueue)localPrinterEnumerator.Current;
            }

            if (printQueue != null) {
                pDialog.PrintQueue = printQueue;
                FixedDocument document = this.CreateFixedDocument();
                pDialog.PrintDocument(document.DocumentPaginator, string.Empty);
            }
        }
    }

Inheritance

Object
DevExpress.XtraRichEdit.Layout.Export.RichEditPrinterBase
XpfRichEditPrinter
See Also