Back to Devexpress

RichEditDocumentServer.Print(PrinterSettings) Method

officefileapi-devexpress-dot-xtrarichedit-dot-richeditdocumentserver-dot-print-x28-system-dot-drawing-dot-printing-dot-printersettings-x29.md

latest4.5 KB
Original Source

RichEditDocumentServer.Print(PrinterSettings) Method

Prints the document with the given printer settings.

Namespace : DevExpress.XtraRichEdit

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
public void Print(
    PrinterSettings printerSettings
)
vb
Public Sub Print(
    printerSettings As PrinterSettings
)

Parameters

NameTypeDescription
printerSettingsPrinterSettings

A PrinterSettings instance containing printer settings.

|

Remarks

Call the Print method to specify the desired options (define the printer name, the number of copies, the paper size, enable double-sided printing, etc.) to print the document.

Note

PrinterSettings properties, such as PageSettings.Margins or PageSettings.Landscape (accessible by the PrinterSettings.DefaultPageSettings property), do not affect the layout of a printed document. Change the settings of a document section (accessed by the Section.Page property) to modify the document page layout properties before printing.

Warning

The Print(PrinterSettings) method overload works only on Windows OS. The PlatformNotSupportedException is thrown on other operating systems. Use the Print method overloads with DXPrinterSettings printerSettings parameter to print on other operating systems.

Example

View Example

csharp
using DevExpress.XtraRichEdit;
using System.Drawing.Printing;

using (var wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument("Grimm.docx");

    PrinterSettings printerSettings = 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: 
    wordProcessor.Print(printerSettings);
}
vb
Imports DevExpress.XtraRichEdit
Imports System.Drawing.Printing

Using wordProcessor = New RichEditDocumentServer()
    wordProcessor.LoadDocument("Grimm.docx")

    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: 
    wordProcessor.Print(printerSettings)
End Using

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Print(PrinterSettings) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

word-document-api-print-documents/CS/Program.cs#L55

csharp
//Print the document:
server.Print(printerSettings);
#endregion #PrinterSettings

word-document-api-print-documents/VB/Program.vb#L36

vb
' Print document
    server.Print(printerSettings)
End Using

See Also

RichEditDocumentServer Class

RichEditDocumentServer Members

DevExpress.XtraRichEdit Namespace