A newer version of this page is available. Switch to the current version.


  • 4 minutes to read

This document outlines the techniques used to print from the RichEditDocumentServer. It consists of the following sections:

RichEditDocumentServer allows you to print a document with the default settings without end-user interaction. Use the RichEditDocumentServer.Print method as shown below to complete the task:

server.Document.AppendDocumentContent("Documents\\Grimm.docx", DocumentFormat.OpenXml);

Change Printer Settings

Pass the System.Drawing.Printing.PrinterSettings instance and call the RichEditDocumentServer.Print method to specify printer options (page range, number of copies, etc.).

Dim printerSettings As New PrinterSettings()

'Set the document pages to print:
printerSettings.FromPage = 2
printerSettings.ToPage = 3

'Specify the number of copies:
printerSettings.Copies = 2

'Print the document:

You can specify additional print settings (to print the comment background color or update document variables before printing) using the PrintingOptions class properties. Use the RichEditControlOptionsBase.Printing property to access an object, as shown below:

PrintingOptions printOptions = richEditDocumentServer1.Options.Printing;
printOptions.EnableCommentBackgroundOnPrint = true;
printOptions.EnablePageBackgroundOnPrint = true;

DevExpress Printing Library (WinForms)

Use the DevExpress Printing Library to set options that are unavailable from RichEditDocumentServer directly. The PrintableComponentLink class from this library allows you to change print settings (e.g., use a specific printer or disable error messages). Use the API from the table below as shown in the following code snippet to complete the task.

private static void PrintViaLink(RichEditDocumentServer srv)
    if (!srv.IsPrintingAvailable) return;
    PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());
    link.Component = srv;
    // Disable warnings.
    link.PrintingSystem.ShowMarginsWarning = false;
    link.PrintingSystem.ShowPrintStatusDialog = false;
    // Find a printer containing 'Canon' in its name.
    string printerName = String.Empty;
    for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++) {
        string pName = PrinterSettings.InstalledPrinters[i];
        if (pName.Contains("Canon")) {
            printerName = pName;
    // Print to the specified printer.

RichEditDocumentXpfPrinter (WPF)

Create a FixedDocument using the RichEditDocumentXpfPrinter.CreateFixedDocument method and utilize the PrintDialog class to print this document from the RichEditDocumentServer.

RichEditDocumentServer srv = new RichEditDocumentServer();

FixedDocument document = RichEditDocumentXpfPrinter.CreateFixedDocument(srv);

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

    if (!localPrinterEnumerator.MoveNext())
    printQueue = (PrintQueue)localPrinterEnumerator.Current;
while (!printQueue.FullName.Contains("Canon"));
if (printQueue != null)
    pDialog.PrintQueue = printQueue;
    pDialog.PrintDocument(document.DocumentPaginator, string.Empty);

Export to PDF (ASP.NET)

Use the RichEditDocumentServer.ExportToPdf method which sends PDF output to a stream, as illustrated in the following code snippet:


Create the PdfExportOptions instance, set its PdfExportOptions.ShowPrintDialogOnOpen property to true and pass this object to the RichEditDocumentServer.ExportToPdf method to show the Print dialog when opening the file.

RichEditDocumentServer documentServer = new RichEditDocumentServer();
// Your code here to create, load or modify a document in the RichEditDocumentServer
using (MemoryStream stream = new MemoryStream())
    PdfExportOptions options = new PdfExportOptions();
    options.ShowPrintDialogOnOpen = true;
    stream.Seek(0, SeekOrigin.Begin);
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition", "inline; filename=ExportedPdf.pdf");

If an application is hosted on Microsoft Azure, set the AzureCompatibility.Enable property to true.

See Also